模拟. 连续的一段$a$合成一个$b$.每段中如果数字只有$1$个,那么可以合成.如果数字个数大于等于$2$个,如果都是一样的,那么无法合成,否则要找到一个可以移动的最大值位置开始移动.一开始写了一个模拟,没考虑到严格大于,$WA$在$106$组数据了...... #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include&…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doc…
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue fo…
[题目描述] Elections are coming. You know the number of voters and the number of parties — n and m respectively. For each voter you know the party he is going to vote for. However, he can easily change his vote given a certain amount of money. In particu…
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue fo…
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue fo…
Epidemic in Monstropolis 题目链接:http://codeforces.com/contest/733/problem/C 贪心 新序列的m个数肯定是由原序列的连续的m个子序列构成的,只需要找到每个连续子序列中最大的数即可. 细节中需要注意:一个连续子序列可能有很多个最大数,最大数的左右两个数必须要有一个小于这个数:还有下标的处理. 代码如下: import sys n = int(input()) a = [int(x) for x in input().split()…
题目连接:Codeforces 437C  The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int MAX_N = 1000 + 10; int G[MAX_N][MAX_N]; struct…
https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则,假如u在v相邻前面,那么u和v可以交换位置,问你是队列最后一个人的时候你最前可以换到前面哪里 题解 因为相邻才能换,所以最后一个换到前面一定是一步一步向前走,所以不存在还要向后走的情况 设最后一个为u,假设前面有一个能和u换位置的集合,那么需要将这些点尽量往后移动去接u 假设前面有一个不能和u换位置的集合S,…
http://codeforces.com/problemset/problem/733/C 题意:给出一个序列的怪兽体积 ai,怪兽只能吃相邻的怪兽,并且只有体积严格大于相邻的怪兽才能吃,吃完之后,这只怪兽的体积会变成原体积 + 吃的怪兽的体积,接下来给出 k 个怪兽的体积 bi,问能不能满足经过一系列操作后让剩下的怪兽体积变得满足下面的序列. 思路:昨晚想的时候觉得好复杂,今天补题发现实际上只有一种情况,就是每一个区间里的怪兽体积对应于一个 bi,然后拆成 k 个区间,分别找区间里面最大的去…