随笔分类 -  贪心

摘要:明显的贪心#include <stdio.h>#include <iostream>#include <vector>#include <algorithm>using namespace std;struct BaoBei{ int p, m; double val;};bool cmp(const BaoBei &a, const BaoBei &b){ return a.p > b.p; // >号 降序排序}int main(){ int v, n; vector<BaoBei> vec; whil 阅读全文
posted @ 2011-04-20 17:46 L.. 阅读(398) 评论(0) 推荐(0)
摘要:1.如果没有重合,总时间为102.影响搬运时间的是两个区间的重合,每次重合时间加103.从整体上看,每10分钟选择全部不冲突的区间搬运,程序上用一个cover数组记录区间被覆盖的次数,最后比较最大值,得到最大时间#include <iostream>#include <string.h>using namespace std;int main(){ int t; int cover[200]; cin >> t; while( t-- ){ memset(cover, 0,sizeof(cover)); int n, s, f; cin >> n 阅读全文
posted @ 2011-04-20 03:43 L.. 阅读(201) 评论(0) 推荐(0)
摘要:/*先按l排序 再每次找出一段最长的递增序列!*/#include <stdio.h>#include <stdlib.h>#include <string.h>struct stick{ int l, w;}st[50010];bool used[50010];int cmp(const void *a, const void *b){ stick *s1 = (stick*)a, *s2 = (stick*)b; if(s1 -> l == s2 -> l) return s1 -> w - s2 -> w; return s1 阅读全文
posted @ 2011-04-09 03:13 L.. 阅读(151) 评论(0) 推荐(0)
摘要:/*抄书上的程序..用c语言写的老是WA每次选效益最高的交换*/#include <iostream>#include <fstream>#include <vector>#include <algorithm>using namespace std;struct Mouse{ double j,f; double shouyi;};bool comp(const Mouse &d1,const Mouse &d2){ if(d1.shouyi != d2.shouyi) return d2.shouyi < d1.shou 阅读全文
posted @ 2011-04-09 03:09 L.. 阅读(201) 评论(0) 推荐(0)