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 ...
随机推荐
- 2020/2/1 PHP代码审计之任意文件读取及删除漏洞
在开始学习之前先简单记录一下自己现在的思路吧..现在接触的基本都是无防护的漏洞也就是最简单的一些漏洞.我的想法就是以代审思路为主,之前一直在打CTF,白盒的思维我觉得和CTF这种黑盒有很大区别.自己的 ...
- CountUp.js 数字跳转效果小插件
CountUp.js 实现数字跳转效果的小插件 //调用方法 const easingFn = function (t, b, c, d) { var ts = (t /= d) * t; var ...
- 远程桌面,出现身份验证错误,要求的函数不正确,这可能是由于CredSSP加密Oracle修正
问题点: 升级至win10 最新版本10.0.17134,安装最新补丁后无法远程win server 2016服务器,报错信息如下: 出现身份验证错误,要求的函数不正确,这可能是由于CredSSP加密 ...
- MySQL的优化与执行
MySQL会解析查询,并创建内部数据结构(解析树),然后对其进行各种优化,包括重写查询.决定表的读取顺序,以及选择合适的索引等.用户可以通过特殊的关键字提示(hint)优化器,影响它的决策过程.也可以 ...
- 吴裕雄--天生自然 PHP开发学习:条件语句
<?php $t=date("H"); if ($t<"20") { echo "Have a good day!"; } ?& ...
- 面试准备 DOM
基本概念:Dom事件的级别 Dom0 级别 element.onclick=function() {} Dom1 没有制定事件相关的 Dom2 element.addEventListener(&q ...
- javaweb02
第一个web服务器程序:开发部署到Tomcat服务器下运行 1).在eclipse新建一个Javaproject2).在java项目下创建web开发的目录结构 -Webcontent -WEB-INF ...
- share团队冲刺8
团队冲刺第八天 昨天:完善代码,解决其中的问题 今天:将除登陆界面之外的界面进行修改和完善,使其美观 问题:bindview不会用,使用时出现问题
- dozer
1.简介 dozer是用来两个对象之间属性转换的工具,有了这个工具之后,我们将一个对象的所有属性值转给另一个对象时,就不需要再去写重复的set和get方法了. 2.如果两个类之间的属性有些属性意思一样 ...
- Aras Innovator客户端批量下载关联文件
<button onclick="btnDownload();" id="downfilebtn">批量下载关联文件</button> ...