LINK:Multiple Testcases 得到很多种做法.其中O(n)的做法值得一提. 容易想到二分答案 check的时候发现不太清楚分配的策略. 需要先考虑如何分配 容易发现大的东西会对小的产生影响 而 对于某个能放的位置 我们放大的一定比小的要优.所以为了防止出现对小的影响到了需要调整的局面和放大的的局面不会比放小的差的思想 可以得到策略. 有了贪心的思路 可以考虑先放大的 考虑对于每个桶中从大到小放. 放完一个数字之和容易二分到下一个位置 然后set取出相应的值即可.复杂度nlogn…
The link to problem:Problem - D - Codeforces   D. Range and Partition  time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Given an array a of n integers, find a range of values [x,y] (x≤y…
Heap Partition Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A sequence S = {s1, s2, ..., sn} is called heapable if there exists a binary tree T with n nodes such that every node is labelled with exactly one element from the se…
题目传送门 /* 贪心/二分查找:首先对ai%=p,然后sort,这样的话就有序能使用二分查找.贪心的思想是每次找到一个aj使得和为p-1(如果有的话) 当然有可能两个数和超过p,那么an的值最优,每次还要和an比较 注意:不能选取两个相同的数 反思:比赛时想到了%p和sort,lower_bound,但是还是没有想到这个贪心方法保证得出最大值,还是题目做的少啊:( */ #include <cstdio> #include <algorithm> #include <cst…
F - 贪心+ 二分 Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Description   A set of n<tex2html_verbatim_mark> 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l<tex2html_ver…
Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1566    Accepted Submission(s): 822 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rule…
B. School Marks Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/problem/B Description Little Vova studies programming in an elite school. Vova and his classmates are supposed to write n progress tests, for each test the…
题意:给出一个字符串,有两种操作: 1.插入一个数字  2.交换两个字符   问最少多少步可以把该字符串变为一个后缀表达式(操作符只有*) #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <iostream> #include <cmath> #include <map> #include <…
A B /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a,b) make_pair(a,b) #define pb push_back ][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }}; using namespace std; typedef long long ll; inline v…
LINK:Cover the Tree 最受挫的是这道题,以为很简单 当时什么都想不清楚. 先胡了一个树的直径乱搞的贪心 一直过不去.后来意识到这类似于最经典长链剖分优化贪心的做法 然后那个是求最大值 这个是构造不太一样 最后也没能搞出来. 不过后了我wa了几发之后 我唯一的队友看不下去了 他来做这道题了 最后还是过了这道题.(有一个好队友就是很舒服 可以想到从叶子节点到跟的过程 每个叶子节点必须要向上合并 因为其父亲的那条边需要被覆盖. 这要到达某个节点会有很多叶子节点相遇 此时考虑父亲那条边…