C. Dividing the numbers Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible. Help Petya to split the inte…
A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers - the first column containing integers…
Codeforces Round #452 (Div. 2) A Splitting in Teams 题目链接: http://codeforces.com/contest/899/problem/A 思路: 统计1和2出现的次数,尽量使2能够与1匹配尽可能多用.假设1再匹配完2之后还有剩余,则求出3个1可组成的方案 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn =…
题 OvO http://codeforces.com/contest/899/problem/E Codeforces Round #452 (Div. 2) - e 899E 解 用两个并查集(记为fa和ma), fa用于更新可以合并在一起的段,维护每个段的左端点,右端点,中间有多少个相同的值,和这个段的值得是什么, ma用于跳跃, 具体来说 例如 这组数据 标上序号(第三行是序号) 1.那么首先合并4个5(10-13),显然9所在的段和14所在的段不能合并 那么把13指向9( ma[13]…
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/A Description After a hard day Vitaly got very hungry and he wants to eat his favorite pot…
A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest comm…
A. Splitting in Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There were n groups of students which came to write a training contest. A group is either one person who can write the…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] n为偶数. l = 1, r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两组的和,如果一样的话,分散在两组 差为1否则差为0 n为奇数 l = 2,r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两组的和,如果一样的话,分散在两组 差为0(把1放在那个较少的组) 否则,差为1 1随意放在哪一组都可以 [代码] #in…
D. Dividing Kingdom II 题目连接: http://www.codeforces.com/contest/687/problem/D Description Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so…
D. Dividing Kingdom II   Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. Th…