贪心
青禾script
这个人太弱,所以也不知道能写什么23333
展开
-
[BZOJ 1034] ZJOI 2008 泡泡堂BNB · 贪心
排序以后贪心,每次最强的比较能赢就赢,最弱的能赢就赢,否则就用最弱的去浪掉对面最强的。 最少得分可以用总分减去对方最多得分。 没了。#include #include #include #include using namespace std; const int N=100005; int n,a[N],b[N]; int work(int a[],int b[]){ int原创 2015-05-05 23:14:55 · 595 阅读 · 0 评论 -
[BZOJ 4096] Usaco2013 dec Milk Scheduling · 贪心
因为总共有n头牛,n个时间,所以我们从后往前枚举时间i,然后枚举所有的牛j,在所有可以选的牛中选一个价值最大的。 #include #include #include using namespace std; const int N=100005; int n,t[N],v[N],ans,ad; bool f[N]; int main(){ scanf("%d",&n); for原创 2015-06-20 23:05:51 · 886 阅读 · 0 评论 -
[BZOJ 1029] JSOI 2007 建筑抢修 · 贪心+堆
这题很类似线段覆盖和工作安排,因此考虑用贪心,但是贪心肯定是会被卡的,所以考虑优化。 假设已经花费了now个单位时间,那么对于当前t号建筑,有两种情况: 1.now+t.cost 2.找到之前已经修过的建筑中,花费时间最多的p号建筑,如果p.cost>t.cost,那么再判断一下用t来替换p是否可行,即now+t.cost-p.cost 这个的意义就相当于线段覆盖中,把t和p分别看成两条线原创 2017-07-23 16:17:30 · 349 阅读 · 0 评论