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. mysql第三篇:表操作

    第三篇:表操作 一.什么是表 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,称为表的字段 二.创建表 语法 CREATE TABLE 表名( 字段名1 类型 ...

  2. POJ 1844:Sum ”滚动“数组

    Sum Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10494   Accepted: 6895 Description ...

  3. pyecharts绘制地图可视化

    pyecharts:官方文档 我们这里使用pyecharts模块进行绘图. pyecharts 项目包含了一系列的地理地图数据,这些数据或者已经内置,或者需要额外安装和加载,我们需要下载下面六个包. ...

  4. Redis 在NETCore中的应用

    Redis 在NETCore中的应用 Redis 在netFramework中的应用  也一样 新建.NETCORE(webapi)项目 安装NuGet //查询NuGet语句 Find-Packag ...

  5. linux上大文件切割成小文件传输

    使用tar命令进行压缩,使用split进行切割 压缩并分割: tar -zcvf - admin- |split -b 100m -d admin-.tar.gz 解压: 先合并成tar包在解压 ca ...

  6. AI 领域与概述

    概述 数据分析行业主要的职业发展. 业务:业务分析师.数据产品经理.产品总监 技术:算法师.架构师.研发经理.研发总监 美工:BI工程师 人工智能,是数据分析的子集.人工智能主要包括 语音识别 自然语 ...

  7. MySQL--数据导入

    参考:http://blog.csdn.net/jyb2014/article/details/39294879?locationNum=13 可导入大文件. source 导入总是失败.

  8. jsp的appilication.getInitParameter()方法无法获取到值的问题

    背景介绍 今天研究jsp的内置对象时发现,使用appilication.getInitParameter()从web.xml文件中获取值的时候,死活获取不到,折腾了将近一个小时,后来出现问题的原因却让 ...

  9. 系统学习python第四天学习笔记

    1.解释 / 编译补充 编译型:代码写完后,编译器将其变成成另外一个文件,然后交给计算机执行. 解释型:写完代码交给解释器,解释器会从上到下一行行代码执行:边解释边执行. [实时翻译] 2.字符串功能 ...

  10. php多态模拟

    在PHP中,多态是最常用到的一种特性.所谓多态,是指同一个东西不同形态的展示.在PHP中,我们这样定义多态,一个类被多个子类继承,如果这个类的某个方法在多个子类中表现不同的功能,那么这种行为我们就称其 ...