
贪心二分
plusplus7
萌系大学生一枚。。。。
展开
-
POJ 1328 Radar Installion
贪心,还是做了好久。 各种错误的思路。。。诶。。。 最后还是学习的别人的。。 把问题转化成多个区间内,寻找最少的点,使得每个区间都有至少一点。。 #include #include #include #include #include using namespace std; struct T { double x; double y; }; T p[1200],原创 2012-11-13 22:05:07 · 525 阅读 · 0 评论 -
BNUOJ 4151 Buying Feed II
Elite 2010 January Competition USACO Contest, SILVER DIVISION 题意:一条直线长度为e上,有n个站点,每个站点上有1个或多个购物点。你需要在这n个站点上买到k磅物品。每个站点可以以C_i的价格卖给FJ 最多F_i磅东西。其中FJ的移动是单向的,且载在t磅东西移动y个单位,会造成t*y的额外消费。求使得最终消费最小。 题解:把每个站点的原创 2013-01-30 22:06:25 · 558 阅读 · 0 评论 -
BNUOJ 4156 Chocolate Buying
贪心,每次都找价值最小的巧克力。做的时候很怕爆long long,结果1Y了。 #include #include #include using namespace std; struct T { long long p; long long c; }; T f[110000]; bool cmp(T a,T b) { return a.p<b.p; } int m原创 2013-01-09 11:08:51 · 455 阅读 · 0 评论 -
POJ 2181 Jumping Cows
给你n个药的序列,牛从时间1开始吃药,在奇数时间吃药可以增加弹跳力,在偶数时间吃药则会减少弹跳力。在某一时间,你可以跳过一些药,但一旦吃过某种药,你就不能在选前面的药了。问你某一个吃药的序列,使牛最终的弹跳力最大。 解法有多种,可以dp,可以贪心。 动态规划: dp[i][0] 表示 当拿到第i个药时,之前已经拿了奇数个药的最大弹跳力。 dp[i]原创 2013-01-08 01:02:32 · 1274 阅读 · 0 评论 -
POJ 3903 Stock Exchange
最长递增序列 #include #include #include using namespace std; int tmp[100010],lt; int main() { int n,i,j,mi,ma,mid,t; while (scanf("%d",&n) != EOF) { lt=0; tmp[lt]=-99999999;原创 2013-01-06 22:43:05 · 486 阅读 · 0 评论 -
POJ 3122 Pie
题意就是给你n个饼的半径,和主人朋友的数量f,问怎么样分饼可以使得每人都从一个饼里分得相同面积的饼。 解法就二分和那个Expanding Rods一样,注意F不是人的总数,要加上主人,所以正确的人数应该是f+1,eps控制在1e-4就ok了,太小会超时。 #include #include #include #define PI acos(-1) #define ep原创 2012-12-30 11:56:59 · 429 阅读 · 0 评论 -
POJ 3258 River Hopscotch
题意:给你n个点,问你去掉m个点后,使相邻点之间的距离最近的最大。 解法和Monthly Expense差不多~ #include #include #include using namespace std; int a[51000],l,n,m,dis[51000]; bool Check(int p) { int i,ite,cnt; ite=0; cnt=原创 2012-12-29 11:37:32 · 500 阅读 · 0 评论 -
POJ 3273 Monthly Expense
二分~ #include #include using namespace std; int main() { int n,m,i,mi,mid,ma,t,ts,a[110000]; scanf("%d%d",&n,&m); mi=0; ma=0; for (i=0; i<n; i++) { scanf("%d",a+i);原创 2012-12-29 11:39:55 · 356 阅读 · 0 评论 -
POJ 3253 Fence Repair
贪心水题,用优先队列水过 #include #include #include #include using namespace std; long long ans,tll; priority_queue, greater > q; int main() { int n,i,j,t; while (!q.empty()) q.pop(); sca原创 2012-11-19 23:54:01 · 470 阅读 · 0 评论 -
POJ 2586 Y2K Accounting Bug
读题。。 对于每一个月来说,是盈利如果则盈利S,如果亏空则亏d。 每五个月进行一次统计,共统计八次(1-5月一次,2-6月一次.......) 统计的结果是这八次都是亏空。 问题:判断全年是否能盈利,如果能则求出最大的盈利。 如果不能盈利则输出Deficit #include using namespace std; int main() { int t,a,b; whi原创 2012-11-13 22:48:17 · 478 阅读 · 0 评论 -
【博客搬家】本博客已全面停止更新,新博客地址 plusplus7.com
新博客地址:http://www.plusplus7.com原创 2013-11-23 21:24:40 · 1414 阅读 · 0 评论