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 ...
随机推荐
- 《机实战》第2章 K近邻算法实战(KNN)
1.准备:使用Python导入数据 1.创建kNN.py文件,并在其中增加下面的代码: from numpy import * #导入科学计算包 import operator #运算符模块,k近邻算 ...
- 读《软件需求最佳实践》YOUGAN
这几天在看<软件需求最佳实践>作者徐锋老师的软件需求培训,三天的课程,虽然原来对需求也关注了很多,自己也做过需求分析和开发的工作,但是这次培训感觉收获还是很多.三天的培训先做个记录,后续多 ...
- Charles下载与破解方法
文章参考:charles4.2下载与破解方法以及配置https 1.Charles官网下载 地址:https://www.charlesproxy.com/latest-release/downloa ...
- JS-语句五
for循环的实例 1.九九乘法表: 1*1 1*2 1*3 1*2 2*2 2*3 1*3 2*3 3*3 1*4 2*4 4*3 ...
- ref与out区别
ref与out out.ref都是传递引用(内存地址),使用后都将改变原来参数的数值. ref 当调用方法时,在方法中会对ref传入的参数数值进行改变,若使用ref参数,则方法定义和调用方法都 ...
- Mdb文件工具类,UCanAccess使用,Access数据库操作
================================ ©Copyright 蕃薯耀 2020-01-09 https://www.cnblogs.com/fanshuyao/ 使用Ocbc ...
- viewer.js插件简单使用说明
不需要依赖jQuery.js,只需要导入viewer.js和viewer.css文件即可. 插件GitHub地址:https://github.com/fengyuanchen/viewerjs 示例 ...
- NABCD模型——星遇
我们项目是个面向希望有新奇体验的用户的社交软件,致力于打造不一样的有趣的社交. 发表后一周预计用户量:1000人 N:(Need,需求) 目前主流社交软件由于时间原因体量越来越大,各种繁琐而不必要的功 ...
- 吴裕雄--天生自然 PHP开发学习:超级全局变量
<!DOCTYPE html> <html> <body> <?php $x = 75; $y = 25; function addition() { $GL ...
- LGOJ4299 首都
这题是 \(LCT\) 维护子树信息中的 \(LCT\) 维护重心 Description link 题意概述:给定一个森林,要求支持以下操作 1.链接两个点 2.求一个点所在树的重心 3.求所有重心 ...