poj 1042 贪心
来源:互联网 发布:淘宝网天猫大码女装 编辑:程序博客网 时间:2024/05/22 22:17
题解见我的另一篇文章点击打开链接
这提要注意的是有些湖是到不了的
一组数据:
310 76 500 30 720 13ans:60, 0, 0Number of fish expected: 0AC代码如下:
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <queue>using namespace std;int main(){int N, H;int f[30], d[30], t[30];while( cin >> N && N ){cin >> H;for( int i = 1; i <= N; i++ ){cin >> f[i];}for( int i = 1; i <= N; i++ ){cin >> d[i];}for( int i = 1; i < N; i++ ){cin >> t[i];}int fishtimes, ans_times[30], max_ans = -1;memset( ans_times, 0, sizeof( ans_times ) );for( int i = 1; i <= N; i++ ){int temp = 0;for( int j = 1; j < i; j++ ){temp += t[j] * 5;}fishtimes = ( H * 60 - temp ) / 5;if( fishtimes < 0 ){ break;}int temp_f[30], temp_ans_times[30], temp_max_ans = 0;memset( temp_ans_times, 0, sizeof( temp_ans_times ) );for( int j = 1; j <= i; j++ )temp_f[j] = f[j];for( int j = 1; j <= fishtimes; j++ ){int tp = 1;for( int k = 1; k <= i; k++ ){if( temp_f[k] > temp_f[tp] ){tp = k;}}temp_max_ans += temp_f[tp];temp_f[tp] -= d[tp];if( temp_f[tp] < 0 ){temp_f[tp] = 0;}temp_ans_times[tp] += 5;}if( temp_max_ans > max_ans ){for( int i = 1; i <= N; i++ ){ans_times[i] = temp_ans_times[i];}max_ans = temp_max_ans;}}cout << ans_times[1];for( int i = 2; i <= N; i++ ){cout << ", " << ans_times[i];}cout << endl;cout << "Number of fish expected: " << max_ans << endl << endl;}return 0;}
0 0
- POJ 1042(枚举+贪心)
- poj 1042 贪心
- poj 1042 贪心
- POJ 1042(贪心)
- 【贪心】poj 1042
- POJ 1042 Gone Fishing(贪心)
- poj 1042 Gone Fishing(贪心)
- POJ 1042:Gone Fishing【贪心】
- poj 1042 Gone Fishing(贪心)
- POJ 1042 贪心+遍历 需要一点点转化
- poj 1042 gone fishing 贪心+枚举
- poj 1042 钓鱼问题 枚举+贪心
- poj 1042 Gone Fishing(贪心 钓鱼)
- POJ 1042 Gone Fishing(贪心+枚举)
- POJ 1042 Gone fishing(枚举+贪心)
- POJ 1042 Gone Fishing (贪心)
- POJ-1042-贪心+枚举+优先队列
- POJ 1042 Gone Fishing(贪心+枚举)
- CMD命令大全
- 表头固定Demo(Div+Css)
- live555 RTSPServer H264-live-streamimg
- 一步步学习SPD2010--第十三章节--管理SP Server环境的Web内容
- 把 MongoDB 当成是纯内存数据库来使用(Redis 风格)
- poj 1042 贪心
- 21世纪了硬盘文件丢失怎么办
- tomcat日志配置之四Spring中配置Log4j
- Android SDK版本和ADT版本
- 手机通讯录乱码怎么恢复
- IMO 双帐号同步API文档
- 因为网站,不得不对链接交换做一番研究
- mysql存储过程的创建,删除,调用及其他常用命令
- 周鸿祎:混日子,会让你失去竞争力