# UVA-1612 Guess Greed

Source: Internet
Author: User

The main topic: There are n contestants to participate in the competition, the title of a total of three, and now give the N players each title score and the final ranking, (each question of the score based on the final check whether to give points, if not through 0 points, by getting the corresponding points), ask the last contestant can get the highest score is how much. (Same score, small ID row front)

The idea of disintegration: to the highest score, the first one must be three questions are right. Maintain a maximum score and the ID number of the previous person
Then judge the next score, if you have the same score, judge the ID number
If the current person's ID number is larger, you just need to update the ID.
If you do not have the same score or the same ID number is smaller than the previous one, find the value that is the highest score and less than the previous person's score.
If the above two conditions are not satisfied, there is no solution.
Note: The equal comparison of decimals can be converted to int first, and the last output divided by 100.0.

``#include <cstdio>#include <algorithm>#include <cmath>#define MAXN 20000using namespace STD;structplayer{intscore;} P[MAXN];intn, ID[MAXN];intMain () {intCAS =1; while(scanf("%d", &n) = =1&& N) {Doubletmp_f;inttmp_i; for(inti =1; I <= N; i++) {scanf("%LF%LF%LF", &tmp_f, &tmp_f, &tmp_f); for(intj =0; J <3; J + +) Tmp_i[j] = (int) (Round (tmp_f[j] *100.0)); for(intj =0; J <8; J + +) {P[i].score[j] =0; for(intK =0; K <3; k++)if(J & (1<< k)) P[i].score[j] + + tmp_i[k]; } sort (P[i].score, P[i].score +8); } for(inti =1; I <= N; i++)scanf("%d", &id[i]);intMAX = p[id].score;intpre_id = id, I; for(i =2; I <= N; i++) {intcur_id = Id[i];BOOLFlag =false; for(intj =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-1612 Guess Greed

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.