![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心
文章平均质量分 71
asuxiexie
这个作者很懒,什么都没留下…
展开
-
hoj Counting the algorithms
贪心加树状数组给出的数据可能出现两种情况,包含与不包含,但我们从右向左删就能避免这个问题;#include#include#includeusing namespace std;const int maxn=200010;int f[maxn],l[maxn],a[maxn];long long tree[maxn];int n;inline int lowbit(int原创 2014-07-21 08:21:43 · 629 阅读 · 0 评论 -
UVA 1422 - Processor (二分+贪心+优先队列)
先对开始时间进行排序,在利用优先队列是结束时间早点先出队;因为时间只有20000,我们可以去枚举每个单位时间,看要给分配给那个任务,如果某个时间队列中还有结束时间大于枚举的时间,就跳出判断是在mid的右边。#include#include#include#include#include#include#includeusing namespace std;原创 2014-08-08 09:01:05 · 779 阅读 · 0 评论 -
UVA 12124 UVAlive 3971 Assemble(二分 + 贪心)
先从中找出性能最好的那个数,在用钱比较少的去组合,能组出来就表明答案在mid的右边,反之在左边,#include#include#include#include#includeusing namespace std;map vic;//以字符映射数字int end,start;int num;int m,n;int sba,sbb;char na原创 2014-08-08 09:10:46 · 688 阅读 · 0 评论 -
hdu 1052 田忌赛马
贪心,排序从大到小。。先比大的,跑不过就拿最小的来送死。。,如果是平局就比后面的。。。若后面也是平局就拿去跟前面的去跑。。。#include#include#include#includeusing namespace std;int s[1005],w[1005];int main(){ int n,i; while(scanf("原创 2014-07-31 19:40:53 · 645 阅读 · 0 评论 -
hud 2570 迷障(水 贪心)
对给的药水浓度进行排序,对于小于解毒药水浓度的可以直接加上它的体积,对每次混合后的药水浓度进行记录,大于解毒药水浓度就输出,注意你求得是百分比还是百分数。。。#include#include#include#includeusing namespace std;int s[10005];int main(){ int a,i,n,m,k; s原创 2014-08-01 16:06:48 · 695 阅读 · 0 评论 -
hdu 4544 湫湫系列故事——消灭兔子 优先队列+贪心
将兔子的血量从小到大排序,箭的威力也从小到大排序,对于每只兔子将威力大于血量的箭加入队列,写个优先队列使得出来数位价钱最少。。#include#include#include#include#includeusing namespace std;const int maxn=100010;struct tt{ int d; int p; bool operator<原创 2014-07-14 20:10:01 · 767 阅读 · 0 评论 -
poj 1328 Radar Installation
开始个人想法是用x坐标从小到大排序,从zuo转载 2014-07-09 09:18:08 · 440 阅读 · 0 评论 -
hdu 1051 Wooden Sticks
简单贪心。将所给数据从小到大进行排序,将所给零件的两数据均小于另一个零件的两数据,看做一个集合。最后输出集合个数。#include#include#include#include#includeusing namespace std;struct www{ int x,y;}s[5005];int yy[5005],a,b;bool cmp(www q,w原创 2014-07-11 08:14:30 · 857 阅读 · 0 评论 -
hdu 1800 Flying to the Mars(水 ,贪心)
其实就是求最大的相同的数的多少。。我是把它当字符串输入。。解决前导0的问题。。#include#include#include#includeusing namespace std;int main(){ char s[35]; int w[3500]; __int64 qq[3500]; int a; while(原创 2014-08-01 14:56:21 · 637 阅读 · 0 评论 -
poj 2573 Bridge (过桥问题 贪心)
对于此问题有两种策略1、最快的带最慢的和次慢的2、最快和次快带最慢和次慢此链接有详细解释点击打开链接#include#include#include#includeusing namespace std;int s[1050];int main(){ int a; scanf("%d",&a); for(int i=0;i<a;i+原创 2014-08-13 10:49:39 · 1052 阅读 · 0 评论