C. The Values You Can Make time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price…
思路: 如果用朴素的方法算O(n^4)超时,这里用折半二分.把数组分成两块,分别计算前后两个的和,然后枚举第一个再二分查找第二个中是否有满足和为0的数. 注意和有重复 #include<iostream> #include<algorithm> #include<cstring> #define ll long long using namespace std; const int N = 4000+5; int a[N],b[N],c[N],d[N]; int mp1…
传送门 4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 20334 Accepted: 6100 Case Time Limit: 5000MS Description The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute…
POJ 2823 Sliding Window 题解 Description An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the slidi…
http://vjudge.net/problem/viewProblem.action?id=37480 East Central Regional Contest Problem C: Hexagon Perplexagon A well known puzzle consists of hexagonal pieces, each with the numbers through printed on the sides. Each piece has a different arrang…