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的更多相关文章

  1. Codeforces Round #576 (Div. 1)

    Preface 闲来无事打打CF,就近找了场Div1打打 这场感觉偏简单,比赛时艹穿的人都不少,也没有3000+的题 两三个小时就搞完了吧(F用随机水过去了) A. MP3 题意不好理解,没用翻译看了 ...

  2. Codeforces Round #576 (Div. 2) 题解

    比赛链接:https://codeforc.es/contest/1199 A. City Day 题意:给出一个数列,和俩个整数\(x,y\),要求找到序号最靠前的数字\(d\),使得\(d\)满足 ...

  3. 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< ...

  4. Codeforces Round #576 (Div. 1) 简要题解 (CDEF)

    1198 C Matching vs Independent Set 大意: 给定$3n$个点的无向图, 求构造$n$条边的匹配, 或$n$个点的独立集. 假设已经构造出$x$条边的匹配, 那么剩余$ ...

  5. [快速幂]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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. scala def方法时等号和括号使用说明笔记

    scala定义方法时会指定入参和返回类型(无返回类型时对应Unit,即java和C中的void模式). 1.有入参,有返回类型时,scala具有类型推导功能,以下两种表达方式效果一样.但根据scala ...

  2. 洛谷 P1020 导弹拦截

    题目传送门 解题思路: 其实就是求一遍最长不上升子序列和最长上升子序列 AC代码: #include<iostream> #include<cstdio> #include&l ...

  3. 19 01 03 css 中 reset 模块 设置

    主要就是让到时候 打入代码时候  把一些bug去除   或者 让一些固有的格式取消 /* 将标签默认的间距设为0 */ body,p,h1,h2,h3,h4,h5,h6,ul,dl,dt,form,i ...

  4. SpringCloud学习之Hystrix请求熔断与服务降级(六)

    我们知道大量请求会阻塞在Tomcat服务器上,影响其它整个服务.在复杂的分布式架构的应用程序有很多的依赖,都会不可避免地在某些时候失败.高并发的依赖失败时如果没有隔离措施,当前应用服务就有被拖垮的风险 ...

  5. h5-web字体和字体图标

    想要使用可以在: https://www.iconfont.cn/webfont?spm=a313x.7781069.1998910419.d81ec59f2#!/webfont/index :是we ...

  6. 谈IO中的阻塞和非阻塞,同步和异步及三种IO模型

    什么是同步和异步? 烧水,我们都是通过热水壶来烧水的.在很久之前,科技还没有这么发达的时候,如果我们要烧水,需要把水壶放到火炉上,我们通过观察水壶内的水的沸腾程度来判断水有没有烧开.随着科技的发展,现 ...

  7. SQL基础教程(第2版)第7章 集合运算:7-2 联结(以列为单位对表进行联结)

    第7章 集合运算:7-2 联结(以列为单位对表进行联结) ■联结的特定语法和过时语法 ● 联结( JOIN)就是将其他表中的列添加过来,进行“添加列”的集合运算.UNION是以行(纵向)为单位进行操作 ...

  8. 华为荣耀magic book(锐龙版)安装ubuntu系统

    荣耀magic book锐龙版性价比很高,前段时间在朋友推荐下我自己也入手了一台.机器整体感觉不错,续航时间长(办公.无线上网5-6小时吧),速度快,买的时候4300,现在已经降到4000以下了,也算 ...

  9. 21. docker 数据通讯环境准备

    一 . 环境搭建 1.编写 Vagrantfile 并创建虚拟机 并虚拟机host绑定外部 192.168.205.10:8888 # -*- mode: ruby -*- # vi: set ft= ...

  10. 收藏基本Java项目开发的书

    一.Java项目开发全程实录 第1章 进销存管理系统(Swing+SQL Server2000实现) 第2章企业内部通信系统(Swing+JavaDB实现) 第3章 企业人事管理系统( Swing+H ...