Codeforces 899 A.Splitting in Teams】的更多相关文章

  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…
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…
CF899A Splitting in Teams 题意翻译 n个数,只有1,2,把它们任意分组,和为3的组最多多少 题目描述 There were nn groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the cont…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 贪心 1优先和2组队. 如果1没有了 就结束. 如果1还有多余的. 那么就自己3个3个组队 [代码] #include <bits/stdc++.h> using namespace std; const int N = 2e5; int n; int a[3]; int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", st…
http://codeforces.com/contest/1092/problem/B There are nn students in a university. The number of students is even. The ii-th student has programming skill equal to aiai. The coach wants to form n2n2 teams. Each team should consist of exactly two stu…
题目链接:http://codeforces.com/contest/872/problem/C 题意: 给你一个数n,问你最多能将n分解成多少个合数之和.(若不能分解,输出-1) 题解: 若要让合数个数最多,则n必定只由4,6,9组成. n由n/4和n%4两部分组成. 四种情况: (1)n%4 == 0: 全分成4就好了,所以ans = n/4 (2)n%4 == 1: 剩下的1要和两个4组合成一个9. 所以如果n/4 >= 2,ans = n/4 - 1 否则ans = -1 (3)n%4…
题意 序列s有n个数,每个数都是不同的,把它每个数分成两个数,组成两个序列a和b,使ab序列各自去掉个数后各自的其它数字都不同. 如果存在一个划分,就输出YES,并且输出两个序列,否则输出NO. 分析 两个月前做的一题,那时候问学长才会做的,现在刚看到题又懵逼了.再做过了一遍. 序列s的每个数都是不同的,我们先给s按递增排序,然后构造:k=   前个数 第二个个数  剩下≤个数 s s[i] s[i+k] s[i+2*k] a s[i] 0   b 0 s[i+k] 0 1 2 ...  ..2…
题目链接:Letters Removing 题意: 给你一个长度为n的字符串,给出m次操作.每次操作给出一个l,r和一个字符c,要求删除字符串l到r之间所有的c. 题解: 看样例可以看出,这题最大的难点在于每次在字符串中删除了前面的字符会对后面的字符产生影响.如何确定当前l和r所指的字符?这里由于对字符的位置查询相当于单点操作区间查询,可以用树状数组维护字符串的前缀和,这样就可以确定l和r的位置了(二分+树状数组 : 复杂度(log(n)×log(n))).再把所有的字符放到set里面进行删除操…
<题目链接> 题目大意: 给定数字n,让你将其分成合数相加的形式,问你最多能够将其分成几个合数相加. 解题分析: 因为要将其分成合数相加的个数最多,所以自然是尽可能地将其分成尽可能小的合数相加的形式.通过找规律,我们能够发现,所有的偶数都能够分成4和6这两个合数的组合,而所有的奇数,在减去9这个最小的奇合数后,就会变成偶数,然后就是和普通偶数一样的处理方式. 普通偶数的处理方式就是,看他能够分成几个4,如果该偶数不为4的倍数,那么就是将其中的一个4换成6.总的最大合数个数为:$n/4$ 而奇数…
  C. Dividing the numbers   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way tha…