技巧
HonniLin
double fighting
展开
-
UVA 11300-Spreading the Wealth
-原创 2014-09-09 23:21:59 · 487 阅读 · 0 评论 -
HDU 5289 - Assignment(multiset + 尺取法)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5289题意:求出序列中有多少个几个使得集合中的数是连续的且任意两个数差值小于k。思路:multiset 储存合格集合,每次新加入的数与最大值和最小值比较。PS:set和map 的find 的复杂度是O(logn),vector 的find的复杂度是 O(n)。AC.#in原创 2015-07-21 21:22:11 · 833 阅读 · 0 评论 -
Codeforces Round #312 (Div. 2) C. Amr and Chemistry(技巧)
题目:点击打开链接题意:n个瓶子,每个瓶子都有相应的水的数量,瓶子的水可以乘2或者除2,求出最少多少步骤可以使瓶子中的所有水相等。思路:将所有瓶子可以到达的毫升数及其步数记录起来,得到可以n个瓶子都能到达的毫升数的最小步数。AC.#include #include #include #include using namespace std;const int原创 2015-07-16 11:59:22 · 528 阅读 · 0 评论 -
Codeforces Round #202 (Div. 2) C. Mafia
题目:http://codeforces.com/problemset/problem/349/C题意:n个人,每个人都有想要作为玩家的次数,每一场比赛必须要有一个评委。求出最少需要多少场比赛才能满足。思路:求出总次数sum,由于每一场比赛可以满足的次数是 (n-1),所以至少需要 sum/(n-1),再同最大的次数相比较。#include #include #incl原创 2015-07-15 21:02:11 · 500 阅读 · 0 评论 -
Codeforces Round #311 (Div. 2) C(技巧) *D(二分图染色)
C. Arthur and Tablehttp://codeforces.com/contest/557/problem/C题意:一张桌子有n条桌腿,每条桌腿有相应的长度和移动花费值,要使桌子平稳,最长桌腿的数量M 与桌腿的数量关系为 M*2>N,求出使桌子平稳的最小花费值。思路:将桌腿按照长度由大到小排序,依次以不同长度的桌腿cnt 作为桌子的平稳支撑,保留另外cnt-1条花费值原创 2015-07-09 16:56:15 · 689 阅读 · 0 评论 -
CSU 1529 - Equator(双端队列)
题目:DescriptionInputOutputSample Input33 1 2 38 4 5 -1 -1 1 -1 -1 52 -1 -1Sample Output6140题意:循环序列,求原创 2015-05-16 22:39:49 · 761 阅读 · 0 评论 -
POJ 2100 - Graveyard Design(尺取法)
题目:http://poj.org/problem?id=2100题意:是否存在一段连续的数, 平方相加等于n, 求出方案数并输出方案.思路:尺取法. AC.#include #include #include using namespace std;typedef long long ll;int ans[1005], x[1005], y[1005]原创 2015-03-11 20:28:36 · 1113 阅读 · 1 评论 -
Codeforces Round #296 (Div. 2) - B. Error Correct System(脑洞)
题目:http://codeforces.com/contest/527/problem/B题意:给出两串n(1 ≤ n ≤ 200 000)个字母的字符串, 求出最多交换一对数, 使得不相同对数变少,求出不相同的对数以及交换的数的位置,若不需交换则输出-1,-1.思路:用矩阵记录两个串相同位置不同的字母, 并记录每一个出现的字母的位置. 计算不相同的对数ans.先枚举一遍原创 2015-03-26 17:36:33 · 729 阅读 · 0 评论 -
UVA 11384 - Help is needed for Dexter(递归)
Problem HHelp is needed for DexterTime Limit: 3 Second Dexter is tired of Dee Dee. So he decided to keep Dee Dee busy in a game. The game he planned for her is quite easy to play but not easy原创 2014-10-05 14:57:30 · 585 阅读 · 0 评论 -
UVA 11464 - Even Parity(枚举方法)
DescriptionD Even Parity Input: Standard Input Output: Standard Output We have a grid of size N x N. Each cell of the grid initially contains a zero(0) or a o原创 2014-10-05 11:11:11 · 617 阅读 · 0 评论 -
UVA 11300-Spreading the Wealth(中位数)
F. Spreading the Wealth ProblemA Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, everyone has con原创 2014-10-02 21:33:58 · 583 阅读 · 0 评论 -
UVA 1030 - Image Is Everything(贪心枚举)
DescriptionYour new company is building a robot that can hold small lightweight objects. The robot will have the intelligence to determine if an object is light enough to hold. It does this by tak原创 2014-10-05 11:23:26 · 599 阅读 · 0 评论 -
HDU 5014-Number Sequence
Problem DescriptionThere is a special number sequence which has n+1 integers. For each number in sequence, we have two rules:● ai ∈ [0,n] ● ai ≠ aj( i ≠ j )For sequence a and sequence b, t原创 2014-09-22 15:45:41 · 626 阅读 · 0 评论 -
HDU 5301 - Buildings(技巧)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5301题意:n*m矩阵,黑格子的位置是(x,y),将剩下位置划分为多个矩阵,每个矩阵必须接触边缘,求出划分矩阵的最大最小面积。思路:将所有的矩阵都变成n如果黑格在两边或者在中线 上下,则面积不变,否则再讨论。AC.#include #include using na原创 2015-07-23 22:53:05 · 870 阅读 · 0 评论