Codeforces Round #407 (Div. 2) B+C!】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/788/B B. Weird journey time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little boy Igor wants to become a traveller. At first, he decided to vi…
人傻不会B 写了C正解结果因为数组开小最后RE了 疯狂掉分 AC:A Rank:392 Rating: 2191-92->2099 A. Functions again 题目大意:给定一个长度为n的数组,求最大的,其中1<=l<r<=n.(n<=10^5) 思路:按左端点所在位置的奇偶性分开计算即可. #include<cstdio> #include<algorithm> using namespace std; #define ll long lo…
来自FallDream的博客,未经允许,请勿转载,谢谢. ------------------------------------------------------ A.Anastasia and pebbles 你有两个口袋,每种口袋最多只能装k个物品,有n种物品,每种物品有ai个,两种不同的物品不能混在一起,问最少要装多少次. 题解:............. #include<iostream> #include<cstdio> #include<cmath>…
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
图论 D. Weird journey time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia…
D. Weird journey time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia. I…
考虑这个二元组中有一者是自环,则必然合法. 考虑这两条边都不是自环,如果它们不相邻,则不合法,否则合法. 坑的情况是,如果它是一张完整的图+一些离散的点,则会有解,不要因为图不连通,就误判成无解. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; ll ans; int n,m,zihuan; int v[2000010],next[2000010],first[200001…
考虑枚举每个子串开头的位置,然后答案转化成询问这个位置之后 哪个位置的前缀和 - 这位置的前缀和 最大(当然是已经把绝对值和正负的情况处理好了,可以发现按奇偶,这个序列只有两种情况),只需要预处理这两个序列的前缀和,以及这两个前缀和序列的后缀max即可. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; int Abs(int x){ return x<0 ? (-x)…
模拟一下那个过程,直到绝对值超过l,或者出现循环为止. 如果结束之后,绝对值是超过l的,就输出当前写在黑板上的数量. 如果出现循环,则如果写在黑板上的数量非零,则输出inf(注意!如果陷入的循环是一个全部被禁止的循环,但是黑板上有输出的值,则还是应该输出黑板上的值的数量.这种情况用循环再向后扫几项判一下即可.),否则输出0. 用三个set处理. #include<cstdio> #include<set> using namespace std; typedef long long…
贪心地一个一个尽可能往口袋里放,容易发现和顺序无关. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; int n,m,a[100100]; ll ans; int main(){ // freopen("a.in","r",stdin); scanf("%d%d",&n,&m); for(int i…