Codeforces Round #576 (Div. 2) D. Welfare State
http://codeforces.com/contest/1199/problem/D

Examples
input1
output1
input2
output2
Note
In the first example the balances change as follows: 1 2 3 4 → 3 3 3 4 → 3 2 3 4 → 3 2 3 4
In the second example the balances change as follows: 3 50 2 1 10 → 3 0 2 1 10 → 8 8 8 8 10 → 8 8 20 8 10
这题很简单 ,可以用线段树做,蒟蒻的我表示不会,只好再另找方法
有两种操作:
操作1(单点修改操作):将x位置处的值变为y
操作2(更新修改操作):输入一个z值,将数组中所有小于z的都改为z
如果没进行单点修改操作,后面更新修改操作的大值会覆盖掉前面更新修改操作的小值
如果该数进行过单点修改操作,那么在该操作之前的操作对该数均无效,只有后面的更新修改操作会生效
如果有10个操作数
c数组形式可能为
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
9 9 9 7 7 3 2 2 0 0
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <math.h>
const int INF=0x3f3f3f3f;
using namespace std;
#define maxn 200010 int a[maxn];//存放数据
int b[maxn];//存放单点修改操作的最后一次操作标号
int c[maxn];//存放更新修改操作,存要修改的值,下标为操作标号 int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
int q;
scanf("%d",&q);
for(int i=;i<=q;i++)
{
int t;
scanf("%d",&t);
if(t==) //单点修改操作
{
int x,y;
scanf("%d %d",&x,&y);
a[x]=y;//直接改值
b[x]=i;//记录该位置最后一次单点操作标号
}
else if(t==)//更新修改操作
{
scanf("%d",&c[i]);//记录该操作标号下的更新处理的值
}
}
for(int i=q-;i>=;i--)//后面大值会覆盖之前的小值,c[1]为最大值
{
c[i]=max(c[i],c[i+]);
}
for(int i=;i<=n;i++)
{
printf("%d ",max(a[i],c[b[i]+]));
}
return ;
}
Codeforces Round #576 (Div. 2) D. Welfare State的更多相关文章
- Codeforces Round #576 (Div. 1)
Preface 闲来无事打打CF,就近找了场Div1打打 这场感觉偏简单,比赛时艹穿的人都不少,也没有3000+的题 两三个小时就搞完了吧(F用随机水过去了) A. MP3 题意不好理解,没用翻译看了 ...
- Codeforces Round #576 (Div. 2) 题解
比赛链接:https://codeforc.es/contest/1199 A. City Day 题意:给出一个数列,和俩个整数\(x,y\),要求找到序号最靠前的数字\(d\),使得\(d\)满足 ...
- Codeforces Round #576 (div.1 + div.2)
Div2 A 长度为\(n(n≤10^5)\)的数组,每个元素不同,求有多少个位置\(d\)满足\(d - x \le j < d \And d < j \le d + y a_d< ...
- Codeforces Round #576 (Div. 1) 简要题解 (CDEF)
1198 C Matching vs Independent Set 大意: 给定$3n$个点的无向图, 求构造$n$条边的匹配, 或$n$个点的独立集. 假设已经构造出$x$条边的匹配, 那么剩余$ ...
- [快速幂]Codeforces Round #576 (Div. 2)-C. MP3
C. MP3 time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Round #223 (Div. 2) A
A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 干货|微软远程桌面服务蠕虫漏洞(CVE-2019-1182)分析
2019年8月,微软发布了一套针对远程桌面服务的修复程序,其中包括两个关键的远程执行代码(RCE)漏洞,CVE-2019-1181和CVE-2019-1182.与之前修复的"BlueKeep ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring基于Annotation装配Bean
在 Spring 中,尽管使用 XML 配置文件可以实现 Bean 的装配工作,但如果应用中 Bean 的数量较多,会导致 XML 配置文件过于臃肿,从而给维护和升级带来一定的困难. Java 从 J ...
- promise 核心 几个小问题
1.如何改变pending的壮体 抛出异常.pending变为rejected // throw new Error('fail') 内部抛出异常也这样 reason为抛出的error resol ...
- ubuntu下面嘚一些常用基本命令
1)环境变量配置: 9 ~/.bashrcor ~/.bash_profile. sudo gedit ~/.bashrc 第一种sudo vim ~/.bashrc export PYTHONPAT ...
- win10编译libpng
libpng在windows的编译. ligpng的官网介绍如下: libpng is the official PNG reference library. It supports almost a ...
- 百度网盘下载神器 PanDownload v2.0.9(破解版、不限速)
一直用这个软件来下载百度网盘的东西,不限速,贼爽. 链接:https://pan.baidu.com/s/1UjF47YWd2v9x52c5sjhutQ 提取码:v9pe 也可以直接到官网下载:ht ...
- zabbix添加主机步骤
创建主机 配置基本信息 配置好后点击添加即可: [root@localhost opt]# systemctl start zabbix-agent [root@localhost opt]# net ...
- windows下关闭自动更新方法
第一种方法: 1.windows+R键打开运行窗口,输入services.msc 2.找到windows update服务右键属性 第二种方法 Win键+R键在弹出的运行对话框中输入gpedit.ms ...
- 吴裕雄--天生自然MySQL学习笔记:MySQL 元数据
你可能想知道MySQL以下三种信息: 查询结果信息: SELECT, UPDATE 或 DELETE语句影响的记录数. 数据库和数据表的信息: 包含了数据库及数据表的结构信息. MySQL服务器信息: ...
- PAT Advanced 1090 Highest Price in Supply Chain (25) [树的遍历]
题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)–everyone inv ...