随笔分类 -  贪心

 
HDU 3351
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3351乍一看很像经典的括号匹配问题,其实不然,因为操作并非增加括号,而是翻转括号只需记录多余的左括号的数量即可,遇到右括号就减去,左括号数量不足就翻转,最后剩余的左括号一半是需要翻转的(转成右括号)#include... 阅读全文
posted @ 2014-11-18 10:13 LegendaryAC 阅读(128) 评论(0) 推荐(0)
HDU 1052
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1052田忌赛马本质就是一个贪心res表示田忌的胜利场次1、田忌最快马快于王的最快马,两个最快马比,res++2、田忌最快马慢于王的最快马,田忌的最慢马和王的最快马比,res--3、田忌最快马等于王的最快马,分三种情... 阅读全文
posted @ 2014-10-29 16:26 LegendaryAC 阅读(302) 评论(0) 推荐(0)
HDU 4864
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4864#include #include #include #include #include #include #include using namespace std ;typedef __int64 ll ;... 阅读全文
posted @ 2014-08-18 09:48 LegendaryAC 阅读(183) 评论(0) 推荐(0)
HDU 4268
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4268学会了multiset的用法,与set不同的是这个可以插入相同元素对w排序,对合适的w用multiset插入对应的h,logn完成查找#include #include #include #include #... 阅读全文
posted @ 2014-07-09 18:40 LegendaryAC 阅读(238) 评论(0) 推荐(0)
HDU 4310 Hero
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4310解题报告正解是状压dp,当时做反正就贪心贪过去了。。。运气真好。。。View Code #include <iostream>#include <algorithm>using namespace std ;typedef struct L{ int dps,hp ; double ab ;}L ;L kk[1001] ;bool cmp(L a,L b){ return a.ab>b.ab ;}int main(){ int n ; while(~scanf(" 阅读全文
posted @ 2012-07-26 18:14 LegendaryAC 阅读(172) 评论(0) 推荐(0)
HDU 1009 FatMouse' Trade
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1009无聊的贪心View Code #include <stdio.h>#include <stdlib.h>typedef struct L{ int j,k; double w;}L;L kk[1001];int cmp(const void*a,const void*b){ L*c=(L*)a; L*d=(L*)b; return d->w > c->w ? 1 : -1 ;}int main(){ int m,n; while(scanf("%d%d 阅读全文
posted @ 2012-05-27 16:45 LegendaryAC 阅读(128) 评论(0) 推荐(0)
HDU 1789 Doing Homework again
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1789贪心,按价值从大到小排序,然后尽可能的安排到截止时间View Code #include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct L{ int a,b;}L;L kk[1100];int cmp(const void*a,const void*b){ L*c=(L*)a; L*d=(L*)b; if(c->b==d->b) return c->a-d->a; r 阅读全文
posted @ 2012-04-23 14:34 LegendaryAC 阅读(132) 评论(0) 推荐(0)
HDU 4221 Greedy?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4221哎,这么简单一道题,愁View Code #include <stdio.h>#include <stdlib.h>typedef struct L{ __int64 c,d;}L;L kk[110000];int cmp(const void*a,const void*b){ return (*(L*)a).d-(*(L*)b).d;}int main(){ int t,n; int i; __int64 time,py; int nCase=1; scanf... 阅读全文
posted @ 2012-04-15 21:13 LegendaryAC 阅读(209) 评论(0) 推荐(0)
HDU 2187 悼念512汶川大地震遇难同胞——老人是真饿了
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2187与2111一样,直接贪心即可View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>struct node{ int p,m;}kk[1100];int cmp(const void*a,const void*b){ struct node*c=(struct node*)a; struct node*d=(struct node*)b; retu 阅读全文
posted @ 2012-04-09 12:15 LegendaryAC 阅读(274) 评论(0) 推荐(0)
HDU 2111 Saving HDU
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2111直接贪心View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>struct node{ int p,m;}kk[110];int cmp(const void*a,const void*b){ struct node*c=(struct node*)a; struct node*d=(struct node*)b; return d->p- 阅读全文
posted @ 2012-04-09 11:28 LegendaryAC 阅读(179) 评论(0) 推荐(0)
BJTU 1623 Problem C. Course Planning
摘要:http://acm.bjtu.edu.cn/problem/detail?pid=1623贪心,关键点是以课程的结束时间为标准排序View Code #include <stdio.h>#include <stdlib.h>struct node{ __int64 x,y;}kk[110000];int cmp(const void*a,const void*b){ struct node*c=(struct node*)a; struct node*d=(struct node*)b; if(d->y==c->y) return d->x-c-&g 阅读全文
posted @ 2012-04-04 12:40 LegendaryAC 阅读(206) 评论(0) 推荐(0)
HDU 2570 迷瘴
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2570这道题WA了十多次,百思不得其解,百度了一组数据12 1 65 7实数运算一定要修正误差View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int main() { int t,n,cnt; int v,w,p[200]; int i,j,f; double q,rz,ry; scanf("%d" 阅读全文
posted @ 2012-04-04 11:44 LegendaryAC 阅读(528) 评论(0) 推荐(0)