贪心
文章平均质量分 90
synapse7
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #227 (Div. 2) / 387C George and Number (贪心)
http://codeforces.com/contest/387/problem/C/*31ms,100KB*/#includechar str[100005];int main(){ gets(str); int i, j, res = 0; for (i = 0; str[i]; i = j) { for (j = i + 1; str[j] == '0原创 2014-03-22 18:12:42 · 1220 阅读 · 0 评论 -
CERC 2004 / UVa 1335 Beijing Guards (二分&贪心&想法题)
1335 - Beijing GuardsTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=4081Beijing was once surrounded by原创 2013-11-11 12:21:48 · 1283 阅读 · 0 评论 -
UVa 1267 Network (DFS&贪心)
1267 - NetworkTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=3708Consider a tree network with n nodes w原创 2013-11-11 08:39:19 · 1135 阅读 · 0 评论 -
UVa 12261 High Score (贪心&“向左走,向右走”)
12261 - High ScoreTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&category=244&page=show_problem&problem=3413思路:注意名字中有若干个A的情况,这时对每串连续的A进行“向左走,原创 2013-11-18 14:32:34 · 2216 阅读 · 0 评论 -
UVa 10718 Bit Mask (贪心&位运算)
贪心思路:从高位往低位考虑,若n的第i位是0,则m需尽量在这一位为1,且在这一位变为1后m<=U;若n的第i位是1,则m需尽量在这一位为0,但m不能太小以至于当L在这一位为1时m<L。完整代码:原创 2013-11-03 19:03:44 · 1666 阅读 · 0 评论 -
UVa 10148 Advertisement (贪心&标记法单个处理)
10148 - AdvertisementTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1089The Department of Recreation ha原创 2013-11-01 23:06:30 · 1354 阅读 · 0 评论 -
UVa 11100 The Trip, 2007 (贪心&一举两得的输出技巧)
贪心思路:最终包的个数k取决于相同规格最多的包的数目(样例中2最多,那k就是2的个数——3)但是题目又要求每组包的数目最小,怎么输出呢?——排序后,间隔k输出即可,因为k是出现最多的数,所以每隔k个输出保证不会相同,同时每组包的数目又最小。完整代码:原创 2013-11-01 20:00:48 · 1710 阅读 · 0 评论 -
UVa 10020 Minimal coverage (贪心&区间覆盖)
10020 - Minimal coverageTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=961The ProblemGiven several原创 2013-10-29 19:28:06 · 1831 阅读 · 0 评论 -
Seoul 2007 / UVa 1398 Meteor (排序&线性扫描)
1398 - MeteorTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=460&page=show_problem&problem=4144The famous Korean internet company nhn h原创 2013-09-05 23:34:45 · 904 阅读 · 0 评论 -
UVa 10382 Watering Grass (贪心&pair使用技巧)
10382 - Watering GrassTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=457&page=show_problem&problem=1323n sprinklers are installed in a原创 2013-09-03 20:43:07 · 933 阅读 · 0 评论 -
UVa 11264 Coin Collector (选硬币&贪心好题)
思路:1. 你肯定注意到了,面值最大的硬币c[n-1]必须要选。(反证:如果花了sum元却没有选中它,可知sum<c[n-1],于是用m+c[n-1]元去兑换可以得到一个更优解。)2. 贪心的关键:假设S(i)是c[1]…c[i] 中那些被选中的货币的面值的和。那么一定有 S(i) < c[i+1]。3. 所以可以构造一个这样的序列出来。按照2中所说,如果有 S(i-1) < c[i]且S(i) =S(i-1)+c[i]<c[i+1],那么c[i]将被选中。完整代码:原创 2013-10-04 11:43:38 · 4539 阅读 · 0 评论 -
Central Europe 1996 / UVa 311 / POJ 1017 Packets (贪心)
311 - PacketsTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=247A factory produces products packed in sq原创 2013-10-31 13:16:55 · 1352 阅读 · 0 评论 -
Codeforces Round #217 (Div. 2) / 370C Mittens (构造&贪心)
http://codeforces.com/contest/370/problem/C/*31ms,0KB*/#include#includeusing namespace std;int C[5005];int main(){ int N, M; cin >> N >> M; for (int i = 0; i > C[i]; sort(C, C + N原创 2014-03-14 20:07:18 · 1285 阅读 · 0 评论 -
Codeforces Round #196 (Div. 2) / 337C Quiz (贪心&快速幂取模)
C. Quizhttp://codeforces.com/contest/337/problem/Ctime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputManao原创 2013-08-17 13:18:57 · 1457 阅读 · 0 评论 -
POJ 1032 / Northeastern Europe 1998 Parliament (贪心)
http://poj.org/problem?id=1032题意:把N个人分成若干组且每组人数不同,每天每组派一个人出来开会,并且每天开会的这群人不与前面的日子的开会人群不完全相同。也就是说,求N1+N2+...+Nn=N,使N1,N2,...,Nn都不相等且他们的乘积最大。思路:分的组越多乘积越大(在题意下ab>a+b)则有分法:设有一连续递增序列为2,3原创 2014-01-13 22:47:12 · 1421 阅读 · 0 评论 -
GCJ 2008 Round 1A A - Minimum Scalar Product (贪心)
http://code.google.com/codejam/contest/32016/dashboardProblemYou are given two vectors v1=(x1,x2,...,xn) and v2=(y1,y2,...,yn). The scalar product of these vectors is a single number, calcul原创 2013-11-07 18:40:28 · 1347 阅读 · 0 评论 -
UVa 757 / POJ 1042 / East Central North America 1999 Gone Fishing (枚举&贪心&想法题&优先队列)
757 - Gone FishingTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=698John is going on a fishing trip. He has h hours a原创 2013-09-27 08:17:38 · 1503 阅读 · 0 评论 -
UVa 1193 / POJ 1328 / Beijing 2002 Radar Installation (贪心&区间选点)
1193 - Radar InstallationTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=3634http://poj.org/problem?id=1328Assume the coasting原创 2013-09-27 07:42:20 · 1972 阅读 · 0 评论 -
UVa 1346 Songs (贪心好题)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=4092思路:直接看这个和式,记A(i)=f(i)Σl(j) (1设sum已经达到最小,记sum1 = A(i)+A(i+1) = (f(i)+f(i+1))*(原创 2013-12-06 13:06:53 · 1278 阅读 · 0 评论 -
Codeforces Round #205 (Div. 2) / 353C Find Maximum (贪心)
C. Find Maximumhttp://codeforces.com/problemset/problem/353/Ctime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2013-10-19 18:23:14 · 1506 阅读 · 0 评论 -
Tokyo 2005 / UVa 1352 Colored Cubes (部分枚举&贪心)
1352 - Colored CubesTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=4098There are several colored cubes.原创 2013-09-04 18:01:26 · 1063 阅读 · 0 评论 -
POJ 3544 Journey with Pigs (贪心&排序不等式)
Journey with Pigshttp://poj.org/problem?id=3544Time Limit: 1000MSMemory Limit: 65536KDescriptionFarmer John has a pig farm near town A. He wants to visit his friend living原创 2013-09-26 07:47:54 · 1415 阅读 · 0 评论 -
Codeforces Round #194 (Div. 1) / 333A Secrets(贪心)
A. Secretshttp://codeforces.com/contest/333/problem/Atime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGe原创 2013-08-17 16:57:22 · 1877 阅读 · 0 评论 -
Codeforces Round #194 (Div. 1) / 333B Chips(贪心+代码优化)
B. Chipshttp://codeforces.com/problemset/problem/333/Btime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputG原创 2013-08-17 22:27:57 · 1476 阅读 · 0 评论 -
Codeforces Beta Round #75 (Div. 2) / 92B Binary Number(贪心)
B. Binary Numberhttp://codeforces.com/problemset/problem/92/Btime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2013-08-17 23:33:29 · 1826 阅读 · 0 评论 -
Codeforces ABBYY Cup 3.0 / 316A1 316A2 Special Task(模拟&贪心&组合数学)
A1&A2. Special Taskhttp://codeforces.com/problemset/problem/316/A1http://codeforces.com/problemset/problem/316/A2time limit per test1 secondmemory limit per test256 megabytes原创 2013-08-13 21:37:33 · 1281 阅读 · 0 评论 -
Codeforces Bayan 2012-2013 Elimination Round / 241A Old Peykan (贪心)
A. Old Peykanhttp://codeforces.com/contest/241/problem/Atime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2013-08-28 16:15:16 · 1116 阅读 · 0 评论 -
Codeforces Round #154 (Div. 2) / 253A Boys and Girls(贪心)
A. Boys and Girlshttp://codeforces.com/problemset/problem/253/Atime limit per test1 secondmemory limit per test256 megabytesinputinput.txtoutputoutput.txtTh原创 2013-08-16 16:03:47 · 1163 阅读 · 0 评论 -
【优化&“调整”思想】VK Cup 2012 Qualification Round 1 / 158B Taxi(贪心)
B. Taxihttp://codeforces.com/problemset/problem/158/Btime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA原创 2013-08-21 16:06:48 · 991 阅读 · 0 评论 -
Codeforces Beta Round #47 / 50A Domino piling(贪心)
A. Domino pilinghttp://codeforces.com/problemset/problem/50/Atime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2013-08-21 18:03:46 · 1330 阅读 · 0 评论 -
UVa 11729 Commando War (贪心)
11729 - Commando WarTime limit: 1.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=2829“Waiting for orders we held in th原创 2013-09-01 11:13:38 · 898 阅读 · 0 评论 -
UVa 11292 / POJ 3646 / HDU 1902 Dragon of Loowater (贪心)
11292 - Dragon of LoowaterTime limit: 1.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=2267Once upon a time, in the原创 2013-09-01 09:37:41 · 972 阅读 · 0 评论 -
POJ 3253 Fence Repair (贪心&优先队列)
z原创 2013-09-24 19:02:51 · 1352 阅读 · 0 评论 -
UVa 10026 Shoemaker's Problem (贪心)
10026 - Shoemaker's ProblemTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=967Shoemaker has N jobs (order原创 2013-09-22 15:05:32 · 1452 阅读 · 0 评论 -
UVa 10827 Maximum sum on a torus (贪心&矩阵环中的最大子矩阵和)
10827 - Maximum sum on a torusTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1768A grid that wraps both h原创 2013-09-20 18:22:33 · 1015 阅读 · 0 评论 -
UVa 108 Maximum Sum (贪心&最大子矩阵和)
108 - Maximum SumTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=44BackgroundA problem that is simple原创 2013-09-19 09:20:27 · 2654 阅读 · 0 评论 -
UVa 507 Jill Rides Again (贪心&最大连续子串和)
507 - Jill Rides AgainTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=448Jill likes to ride her bicycle,原创 2013-09-19 00:18:25 · 1246 阅读 · 0 评论 -
IIUC ONLINE CONTEST 2008 / UVa 11389 The Bus Driver Problem (贪心)
11389 - The Bus Driver ProblemTime limit: 1.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2384In a city there原创 2013-10-03 21:12:43 · 1320 阅读 · 0 评论 -
Codeforces Round #177 (Div. 1) / 288A Polo the Penguin and Strings(贪心)
A. Polo the Penguin and Stringshttp://codeforces.com/problemset/problem/288/Atime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutput原创 2013-08-14 10:04:17 · 1842 阅读 · 0 评论 -
UVa 11520 Fill the Square (贪心&字典序)
11520 - Fill the SquareTime limit: 1.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=2515In this problem, you have to d原创 2013-09-03 12:47:12 · 1110 阅读 · 0 评论