uva 757 - Gone Fishing
来源:互联网 发布:ubuntu 64位下载 编辑:程序博客网 时间:2024/05/17 20:27
#include <cstdio>#include <cstring>#include <cctype>#include <cstdlib>#include <queue>#include <stack>#include <cmath>#include <string>#include <iostream>#include <map>#include <algorithm>using namespace std;#define maxn 25 + 10#define INF 2100000000#define ll long longstruct node{ int no, f, d, t; bool operator < (const node &rha) const{ if(f == rha.f) return no > rha.no; else return f < rha.f; }}l[maxn];priority_queue<node> q;int main(){ int n; bool first = true; while(scanf("%d", &n) != EOF && n) { if(first) first = false; else puts(""); int h; scanf("%d", &h); for(int i = 0; i < n; ++i) { scanf("%d", &l[i].f); l[i].no = i; } for(int i = 0; i < n; ++i) scanf("%d", &l[i].d); l[0].t = 0; for(int i = 1; i < n; ++i) { scanf("%d", &l[i].t); l[i].t += l[i-1].t; } int ans = -INF; int lt[maxn], anslt[maxn]; memset(anslt, 0, sizeof(anslt)); for(int i = 0; i < n; ++i) { memset(lt, 0, sizeof(lt)); while(!q.empty()) q.pop(); for(int j = 0; j <= i; ++j) q.push(l[j]); int tottime = h*60 - l[i].t*5; int sum = 0; node t; while(tottime > 0) { if(!q.empty()) t = q.top(); q.pop(); if(t.f <= 0) break; sum += t.f; t.f -= t.d; lt[t.no] += 5; tottime -= 5; q.push(t); } if(tottime > 0) lt[0] += tottime; if(sum > ans) { ans = sum; for(int k = 0; k <= i; ++k) anslt[k] = lt[k]; } } printf("%d", anslt[0]); for(int i = 1; i < n; ++i) printf(", %d", anslt[i]); printf("\n"); printf("Number of fish expected: %d\n", ans); } return 0;}
0 0
- UVa 757 - Gone Fishing
- UVa 757 - Gone Fishing
- uva 757 - Gone Fishing
- Uva 757 - Gone Fishing
- UVA - 757 Gone Fishing
- uva 757 - Gone Fishing
- UVA 757 Gone Fishing
- Uva 757 Gone Fishing
- UVA 757 Gone Fishing(贪心 + 暴力)
- uva 757 Gone Fishing(贪心)
- UVA - 757 Gone Fishing 贪心+枚举
- uva 757 Gone Fishing (贪心)
- 757 - Gone Fishing
- Gone Fishing
- gone fishing
- Gone fishing
- UVa 757 / POJ 1042 / East Central North America 1999 Gone Fishing (枚举&贪心&想法题&优先队列)
- POJ 1042 Gone Fishing
- erlang list的使用与优化建议
- 人过三十才想明白的那点事:成功的真相
- Windows Server 2008 R2 实现多用户同时登陆
- 鼠标右键添加“删除svn文件夹”菜单
- 格式化MSChart
- uva 757 - Gone Fishing
- vdax ,.a'dfg\ ./cax\.v;.,dcapklvl;]sdtgsdg;l
- HDU 4635 Strongly connected(强连通分量)
- ReportStudio入门教程(四十八) - 对负值进行格式化
- 少年齿长,煌煌昭昭
- TF-IDF与余弦相似性的应用(一):自动提取关键词
- STL之内存处理
- 深入理解PHP内核的大纲
- html js css 遇到的生词