2012年3月29日

USACO section1.3 Barn Repair 修理牛棚(贪心)

摘要: 题目:http://www.wzoi.org/usaco/11%5C304.asp大意:有m个点,用有数量限制的区间把这些点全部覆盖,求区间和的最小值。贪心原理:如果限制的区间数大于等于m的话ans=m(就因为没考虑这点提交了好多次- -|||);否则,先用把点都排序(这里也忘记了- -|||),用标记法记录相邻点的距离,a[i]表示距离为i的个数。。。每减少一次区间的个数相当于2个区间合并成一个区间,合并的话肯定选距离最小的那个。。。。。把区间个数减到限制的个数为止。。。。。。/*ID: qiufeih1PROG: barn1LANG: C++*/#include <iostream& 阅读全文

posted @ 2012-03-29 22:23 [S*I]SImMon_WCG______* 阅读(873) 评论(0) 推荐(0) 编辑

USACO section1.3 Mixing Milk 混合牛奶

摘要: 题目:http://www.wzoi.org/usaco/11%5C302.asp水题。。。。。。。按价格升序后,从头开始选。/*ID: qiufeih1PROG: milkLANG: C++*/#include <iostream>#include <fstream>#include <cstring>#include <algorithm>using namespace std;const int INF = 1<<30;struct farmer{ int price, num;}a[5010];bool Cmp(farmer 阅读全文

posted @ 2012-03-29 17:12 [S*I]SImMon_WCG______* 阅读(231) 评论(0) 推荐(0) 编辑

USACO section1.2 Milking Cows 挤牛奶(区间覆盖)

摘要: 题目:http://www.wzoi.org/usaco/12%5C211.asp额。。。。纠结了很久。。。。开始没区别时间和时刻。。。。区间是(star,end]都赋值为1/*ID: qiufeih1PROG: milk2LANG: C++*/#include <iostream>#include <fstream>#include <cstring>using namespace std;const int INF = 1<<30;int a[1000001];int main(){ freopen("milk2.in", 阅读全文

posted @ 2012-03-29 12:46 [S*I]SImMon_WCG______* 阅读(423) 评论(0) 推荐(0) 编辑

导航