UVA - 757 Gone Fishing
来源:互联网 发布:条码打印软件使用方法 编辑:程序博客网 时间:2024/05/17 23:49
题意:参考点击打开链接
#include <iostream>#include <cstdio>#include <cstring>#include <queue>using namespace std;const int MAXN = 35;int h,n;int ans[MAXN],tmp[MAXN];struct Node{ int no; int rate; int down; int time; friend bool operator < (const Node &a,const Node &b) { if (a.rate != b.rate) return a.rate < b.rate; return a.no > b.no; }}arr[MAXN];priority_queue<Node>que;void greedy(){ int maxsum = -11111; for (int i = 0; i < n; i++) { while (!que.empty()) que.pop(); for (int j = 0; j <= i; j++) que.push(arr[j]); int leftTime = h * 60 - arr[i].time,sum = 0; memset(tmp,0,sizeof(tmp)); while (leftTime > 0) { Node temp = que.top(); que.pop(); if (temp.rate <= 0) break; sum += temp.rate; temp.rate -= temp.down; tmp[temp.no] += 5; que.push(temp); leftTime -= 5; } if (leftTime > 0) tmp[0] += leftTime; if (sum > maxsum) { maxsum = sum; for (int j = 0; j < n; j++) ans[j] = tmp[j]; } } printf("%d",ans[0]); for (int i = 1; i < n; i++) printf(", %d",ans[i]); printf("\n"); printf("Number of fish expected: %d\n",maxsum);}int main(){ bool flag = false; while (scanf("%d",&n) != EOF && n) { scanf("%d",&h); for (int i = 0; i < n; i++) { scanf("%d",&arr[i].rate); arr[i].no = i; } for (int i = 0; i < n; i++) scanf("%d",&arr[i].down); arr[0].time = 0; for (int i = 1; i < n; i++) { int t; scanf("%d",&t); arr[i].time = arr[i-1].time + t * 5; } if (flag) printf("\n"); else flag = true; greedy(); } return 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
- Hook linux 网络封包
- 基于泛型类模块,使类成员函数作为回调函数
- 黑马程序员 .NET学习笔记 <10>
- JAVA面试宝典
- Spring2.5那些事之基于AOP的方法级注解式日志配置
- UVA - 757 Gone Fishing
- WebService 之 WSDL文件 讲解
- 编程规范
- SSH 分页方法一,基于struts2
- ASM 2——raw设备绑定
- android中activity的launchMode对onActivityResult()方法的影响
- Linux 驱动分析--s3c6410 的SDIO驱动分析
- 生成WSDL文件的三种方法
- android PendingIntent