UVA 1612 Guess
2015-10-21 23:51
369 查看
#include<cstdio> #include<algorithm> #include<cmath> #define maxn 20000 using namespace std; struct player{ int score[8]; }P[maxn]; int n, ID[maxn]; int main() { int cas = 1; while(scanf("%d", &n) == 1 && n) { double tmp_f[3]; int tmp_i[3]; for(int i = 1; i <= n; i++) { scanf("%lf%lf%lf", &tmp_f[0], &tmp_f[1], &tmp_f[2]); for(int j = 0; j < 3; j++) tmp_i[j] = (int)(round(tmp_f[j] * 100.0)); for(int j = 0; j < 8; j++) { P[i].score[j] = 0; for(int k = 0; k < 3; k++) if(j & (1 << k)) P[i].score[j] += tmp_i[k]; } sort(P[i].score, P[i].score + 8); } for(int i = 1; i <= n; i++) scanf("%d", &ID[i]); int MAX = P[ID[1]].score[7]; int pre_ID = ID[1], i; for(i = 2; i <= n; i++) { int cur_ID = ID[i]; bool flag = false; for(int j = 7; j >= 0; j--) { if(P[cur_ID].score[j] == MAX && cur_ID > pre_ID) { flag = true; pre_ID = cur_ID; break; } if(P[cur_ID].score[j] < MAX) { flag = true; pre_ID = cur_ID; MAX = P[cur_ID].score[j]; break; } } if(!flag) break; } printf("Case %d: ", cas++); if(i != n + 1) printf("No solution\n"); else printf("%.2lf\n", MAX / 100.0); } return 0; }
相关文章推荐
- UVA_1605: Building for UN
- CodeForces - 369E Valera and Queries(树状数组)
- IOS-UI控件大全
- 2015/10/21 UICollectionViewController 使用
- Under the Hood: Rebuilding Facebook for Android
- STL学习笔记-priority quene容器(优先级队列)
- STL学习笔记-quene容器(队列)
- STL学习笔记-deque容器(双端动态数组)
- DOTween 模仿NGUI Tween
- 【IOS 开发学习总结-OC-63】UIImage 与 CGImage,CGImageRef
- 黑马程序员--GUI
- String、StringBuffer和StringBuilder的异同和用法
- 【UIKit-106-1】UISwitch - 基础使用
- UVA-11324 The Largest Clique (强连通+DP)
- 斯坦福大学公开课 iOS应用开发教程学习笔记(第六课)多个MVC的程序和故事版、UINavigationController、 Segues
- UIButton详解
- 删除链表中(不带头结点)值为value的结点,返回删除的个数
- percona慢查询分析工具:pt-query-digest使用介绍
- Ui培训之如何设计极简三色图标
- LeetCode---Unique Paths