poj3262】的更多相关文章

一.题目 Description Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eating his beautiful flowers. Wanting to minimize the…
一.题意:有n头牛,每头牛每分钟会吃D个菜,把这头牛赶回去需要时间T(人再返回又需要T),一次只能赶回去一头牛,也就是说剩下的牛会继续吃菜.求牛最少吃多少菜 二.思路:贪心.按D/T将牛进行排序,然后计算即可. 三.代码: #include"iostream" #include"stdio.h" #include"algorithm" #include"string.h" using namespace std; ; type…
Protecting the Flowers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7923   Accepted: 3196 Description Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his ho…
思路: 简单贪心,每次选择性价比最高的. 实现: #include <iostream> #include <cstdio> #include <algorithm> using namespace std; struct node { int t, d; }; int n; node a[]; ]; bool cmp(const node & a, const node & b) { double x = a.d * 1.0 / a.t; double…
Protecting the Flowers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4418   Accepted: 1785 Description Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his ho…
Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eating his beautiful flowers. Wanting to minimize the subsequent damag…
Protecting the Flowers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3204   Accepted: 1300 Description Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his ho…
题意:FJ去砍树,然后和平时一样留了 N (2 ≤ N ≤ 100,000)头牛吃草.当他回来的时候,他发现奶牛们正在津津有味地吃着FJ种的美丽的花!为了减少后续伤害,FJ决定立即采取行动:运输每头牛回到自己的牛棚. 每只奶牛i在离牛棚Ti(1 ≤ Ti ≤ 2,000,000) 分钟路程的地方,每分钟吃掉Di(1 ≤ Di ≤ 100)朵花.FJ只能一次带回一头奶牛.弄回一头奶牛i来回需要2*Ti分钟.从带回i号奶牛开始,i号奶牛就不会吃花.请你找出被毁坏的花的最小数量 . 题解:按照排序贪心…
Problem 1 护花(flower.cpp/c/pas) [题目描述] 约翰留下他的N(N<=100000)只奶牛上山采木.他离开的时候,她们像往常一样悠闲地在草场里吃草.可是,当他回来的时候,他看到了一幕惨剧:牛们正躲在他的花园里,啃食着他心爱的美丽花朵!为了使接下来花朵的损失最小,约翰赶紧采取行动,把牛们送回牛棚. 牛们从1到N编号.第i只牛所在的位置距离牛棚Ti(1≤Ti≤2000000)分钟的路程,而在约翰开始送她回牛棚之前,她每分钟会啃食Di(1≤Di≤100)朵鲜花.无论多么努力…
poj3170 1,4两遍bfs: poj3171 改一改poj2376即可 poj3172 dfs+剪枝 其实增长速度很快,n<=40,题目吓你的: poj3661 比较经典的dp:设f[i,j]为到第i分钟,耗了j精力最长能跑多远: f[i,j]=f[i-1,j-1]+d[i] (j>0); f[i,0]=max{f[i-k][k],f[i-1,0]} (1<=k<=i-k) 注意最后输出的是f[n,0]; poj3660 果然自己还是太弱,水题想了好久:用floyd的传递性判…
POJ3617 Best Cow Line 题意 给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下列任意操作: 从S的头部(或尾部)删除一个字符,加到T的尾部 目标是构造字典序尽可能小的字符串T. 思路 贪心算法,不断取S的开头和末尾中较小的一个字符放到T的末尾.但对于S的开头和末尾字符相同的情况下,需要比较下一个字符大小,这可以用如下算法实现: 按照字典序比较S和S翻转后的字符串S1,如果S较小,则从S的开头取,否则从末尾取. 代码 Source Cod…
一.题面 POJ3262 二.分析 这题要往贪心上面想应该还是很容易的,但问题是要证明为什么比值关系就能满足. 可以选择几个去分析,入1-6  与 2-15  和 1-6 与2-5 和 1-6 与 2- 12. 三.AC代码 #include <cstdio> #include <iostream> #include <algorithm> #include <fstream> using namespace std; ; struct Cow { int…
Protecting the Flowers 直接中文 Descriptions FJ去砍树,然后和平时一样留了 N (2 ≤ N ≤ 100,000)头牛吃草.当他回来的时候,他发现奶牛们正在津津有味地吃着FJ种的美丽的花!为了减少后续伤害,FJ决定立即采取行动:运输每头牛回到自己的牛棚. 每只奶牛i在离牛棚Ti(1 ≤ Ti ≤ 2,000,000) 分钟路程的地方,每分钟吃掉Di(1 ≤ Di ≤ 100)朵花.FJ使尽浑身解数,也只能一次带回一头奶牛.弄回一头奶牛i需要2*Ti分钟(来回…