codeforces 1198B - Welfare State】的更多相关文章

题目链接:http://codeforces.com/problemset/status 题目大意为有n个市民,每个市民有ai点数财富,以下有q次操作,操作类型为两类,1类:把第p个市民的财富改为x,2类:把所有财富小于x的市民的财富变为x. 题目数据量较大,强行n^2暴力模拟会超时,分析题意尝试缩小时间复杂度.观察到在对第i个市民进行最后一次1类操作之后,将不会影响此后的所有第2类操作,也就是说如果此后的第2类操作的x > ai的财富,将可以修改第i个市民的财富,因此每个市民的最终财富 = 对…
[Codeforces 1199D]Welfare State(线段树) 题面 给出一个长度为n的序列,有q次操作,操作有2种 1.单点修改,把\(a_x\)修改成y 2.区间修改,把序列中值<v的数全部修改成v 问q次操作后的序列 分析 主要考虑如何实现操作2,可以通过有条件的下推标记来实现.线段树的叶子节点存储序列的值,上推的时候维护区间最小值.如果给某个节点下推标记的时候发现该节点对于的区间最小值>v,则不下推(最小值>v,即所有数都>v,不用会产生修改),否则把区间中的最小…
https://codeforc.es/contest/1199/problem/D 其实后来想了一下貌似是个线段树的傻逼题. 单调栈是这样思考的,每次单点修改打上一个最终修改的时间戳.每次全体修改就push进去单调栈.首先比新的全体修改的x小的(等的也)全部出栈,这样子单调栈里面就是一个递减的序列,而时间戳是递增的. 最后对于每一个有修改标记的,在时间戳上面二分找到他的下一次修改,那么这个修改绝对就是足够大的.假如没有查找成功,则说明不存在最后一次修改.(可以通过在最后入栈一个0操作来统一),…
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…
There is a country with …
\(对于操作1,我们只关心最后一次操作.\) \(对于操作2,我们只关心值最大的一次操作.\) \(也就是说,我们记录每个居民最后一次被修改的位置\) \(然后它的最终答案就是从这个位置起,max(操作2最大的一次,最后一次修改的值)\) \(当然,如果没有被修改过,默认被修改的位置在0.\) \(\color{Red}{话说回来真的很佩服那些写线段树的人,为什么我不会用线段树呢(●ˇ∀ˇ*|}\) #include <bits/stdc++.h> using namespace std; c…
点此进入比赛 \(A\):MP3(点此看题面) 大致题意: 让你选择一个值域区间\([L,R]\),使得序列中满足\(L\le a_i\le R\)的数的种类数不超过\(2^{\lfloor\frac {8I}n\rfloor}\),输出剩余数的数量的最小值. 对着英文题面懵了半天... 理解题意之后这题就很水了. 考虑我们先排序+离散化,然后选择的数必然是离散化序列上的一段长度为\(2^{\lfloor\frac {8I}n\rfloor}\)的区间. 那么我们枚举区间左端点,双指针维护区间右…
Preface 闲来无事打打CF,就近找了场Div1打打 这场感觉偏简单,比赛时艹穿的人都不少,也没有3000+的题 两三个小时就搞完了吧(F用随机水过去了) A. MP3 题意不好理解,没用翻译看了好久然后就看错了,后来发现是个SB题 考虑我们将数字排序+离散化之后就可以知道一个区间外有多少个数,可以直接计算答案 然后发现这个区间的移动有单调性,因此直接two points扫一下就好了 #include<cstdio> #include<cmath> #include<io…
比赛链接:https://codeforc.es/contest/1199 A. City Day 题意:给出一个数列,和俩个整数\(x,y\),要求找到序号最靠前的数字\(d\),使得\(d\)满足\(a_d<a_j\) (\(d-x\leq j<d\) && \(d<j\leq d+y\)). 分析:由于x和y都小于7,所以直接暴力即可. AC代码: #include <bits/stdc++.h> #define SIZE 200007 #define…
A - Messenger Simulator CodeForces - 1288E 两种解法,我选择了第二种 mn很好求,联系过就是1,没联系过就是初始位置 第一种:统计同一个人两次联系之间的出现的不同的人的个数,这个值用来更新mx[i],模拟一下就可以理解.而在第一次联系之前的部分,由于初始是顺序的,所以只需要统计i第一次联系之前出现的大于i的不同的人的个数,用这个数字和初始位置之和来更新mx[i].对于最后一次联系之后的部分,我们可以假定在m+1的位置再次与其进行联系,然后套用前面两次联系…
Browse Princeton's Series (by Date) in Princeton Economic History of the Western World Joel Mokyr, Series Editor Titles in the Princeton Economic History of the Western World seek to explain the full range of Western economic development in all of it…
准确的标点符号和大写字母可以帮助Tutor准确理解report的意思.标点符号的某些方面,例如使用逗号,可以是一种个人风格,在引号中正确的标点符号是至关重要的.在前面的一些文章当中我们也给大家说了report写作中标点符号的使用方法,本文中小编就给大家说说这个老生常谈的问题,帮助大家在report写作中正确使用标点符号. Capital letters 在现代英语中,很难准确地给出使用大写字母的规则,因为在现代英语中,使用它们的趋势更少.但是,在下列情况下,应该使用它们: (a)句子中的第一个词…
题目链接:http://codeforces.com/problemset/problem/758/A A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expe…
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m g…
Cosmic Tables Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 222B Description The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptiv…
Secret Combination Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 496B Description You got a box with a combination lock. The lock has a display showing n digits. There are two buttons…
Persistent Bookcase Problem Description: Recently in school Alina has learned what are the persistent data structures: they are data structures that always preserves the previous version of itself and access to it when it is modified. After reaching…
A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains…
题目链接:http://codeforces.com/contest/489 A:SwapSort In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps…
Variable, or There and Back Again 题目连接: http://codeforces.com/problemset/problem/164/A Description Life is not easy for the perfectly common variable named Vasya. Wherever it goes, it is either assigned a value, or simply ignored, or is being used! V…
Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consisting only of parentheses '(' and ')' is called balanced if it is one of the following. • A string "()" is balanced. • Concatenation of two balance…
A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya…
D. Regular Bridge Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/D Description An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a b…
A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/problem/A Description Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Ove…
C. Love Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/553/problem/C Description There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie.…
B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/problem/B Description Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clea…
A. Even Odds Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/problem/A Description Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural n…
D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/D Description As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State Uni…
B. Queries on a String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/B Description You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. I…