您的位置:首页 > 产品设计 > UI/UE

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: