努力ing
你浪费的今天是昨天死去的人所渴望的明天!!!

随笔分类 -  贪心

HDU 3177
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3177#include<iostream>#include "algorithm"using namespace std;struct node { int ai; int bi; int ci; bool operator <(const node& x) { return ci>x.ci; //排序两者的差值 }};int main(){ int t,i,j; int v,n; cin>>t; node job[10005]; while(t 阅读全文
posted @ 2013-06-21 17:23 努力ing 阅读(148) 评论(0) 推荐(0)
HDU 1789
摘要:#include<iostream>#include<algorithm>#include<cstring>using namespace std;struct node { int day; int score; bool operator<(const node& x)const{ return score>x.score; }};int main(){ int t,n; int i,j,ans; cin>>t; node job[5005]; int flag[5005]; while(t--) { cin>> 阅读全文
posted @ 2013-06-21 13:31 努力ing 阅读(190) 评论(0) 推荐(0)
hdu 1009 FatMouse' Trade
摘要:因为先没有判断i与n的大小,一直错着,郁闷的不行,蛋都碎了……#include<iostream>#include<algorithm>#include<iomanip>using namespace std;struct node{int java;int food;double agv;};bool cmp(node a,node b){return a.agv>b.agv;}int main(){int i;int m,n;node fat[1005];while(cin>>m>>n&&(m+n)!=-2) 阅读全文
posted @ 2013-05-10 21:21 努力ing 阅读(106) 评论(0) 推荐(0)
Pku 3646
摘要:简单的贪心算法开始的时候真的很郁闷,将第一个for循环中i++写在括号内,当循环j==m时,跳出,i没有自加1;测试数据是过了,以为题目很简单,就没有去测其他数据了,这就悲剧了。#include<iostream>#include<algorithm>using namespace std;int a[20005],b[20005];int main(){int n,m;while(cin>>n>>m,n+m){int num=0,i;for(i=0;i<n;i++)cin>>a[i];for(i=0;i<m;i++)ci 阅读全文
posted @ 2013-05-06 21:49 努力ing 阅读(124) 评论(0) 推荐(0)