hdu1177(Accepted today?)

点击打开杭电1177

Problem Description

Do you remember a sentence "Accepted today?" Yes, the sentence is mentioned frequently in lcy’s course "ACM Programming"!The contest is still in progress this moment. How excited it is! You, smart programmer, must have AC some problems today. "Can I get copper medal, silver medal, or even golden medal?" Oh, ha-ha! You must be considering this question. And now, the last problem of this contest comes.Give you all submitting data in the contest, and tell you the number of golden medals, silver medals and copper medals; your task is to output someone’s contest result.Easy? Of course! I t is the reason that I designed the problem.When you have completed this contest, please remember that sentence〃 Accepted today?〃兒

Input

Input contains multiple test cases. Each test case starts with five numbers N (4 =< N <= 130 — the total number of attendees), G, S, C (1<=G<=S<=C<N –G, S, C denoting the number of golden medals, silver medals and copper medals respectively) and M (0<M<=N). The next N lines contain an integer P (1<=P<=8 –number of problems that have been solved by someone) and a time T(for example,"02:45:17", meaning 2 hours and 45 minutes and 17 seconds consumed according to contest rules) each. You can assume that all submit data are different.A test case starting with 0 0 0 0 0 terminates input and this test case should not to be processed.

Output

For each case, print a sentence in a line, and it must be one of these sentences:Accepted today? I’ve got a golden medal :)Accepted today? I’ve got a silver medal :)Accepted today? I’ve got a copper medal :)Accepted today? I’ve got an honor mentioned :)Note: You will get an honor mentioned if you can’t get copper medal, silver medal or golden medal.

Sample Input

10 1 2 3 62 02:45:172 02:49:012 03:17:582 03:21:294 07:55:483 04:25:423 06:57:392 02:05:022 02:16:452 02:41:370 0 0 0 0

Sample Output

Accepted today? I’ve got a silver medal 🙂

思路:简单的结构体排序,java里用类代替结构体就行了,,很简单。

package xjj;import java.util.Scanner;public class P1177{public static void main(String[] args) {Scanner sc=new Scanner(System.in);while(sc.hasNext()){int n=sc.nextInt();int g=sc.nextInt();int s=sc.nextInt();int c=sc.nextInt();int m=sc.nextInt();if(n+g+s+c+m==0){return ;}Body[] body=new Body[n];for(int i=0;i<n;i++){int num=sc.nextInt();String time=sc.next();body[i]=new Body(num,time);}body[m-1].isMy=true;sort(body);int i;for(i=0;i<n;i++){//System.out.println(body[i].num+" "+body[i].time+" "+body[i].isMy);if(body[i].isMy){break;}}i+=1;if(i<=g){System.out.println("Accepted today? I've got a golden medal :)");}else if(i<=g+s){System.out.println("Accepted today? I've got a silver medal :)");}else if(i<=g+s+c){System.out.println("Accepted today? I've got a copper medal :)");}else{System.out.println("Accepted today? I've got an honor mentioned :)");}}}private static void sort(Body[] body) {Body temp=new Body();for(int i=0;i<body.length-1;i++){for(int j=0;j<body.length-1-i;j++){if(body[j].num<body[j+1].num){temp=body[j];body[j]=body[j+1];body[j+1]=temp;}else if(body[j].num==body[j+1].num){if(body[j].timer>body[j+1].timer){temp=body[j];body[j]=body[j+1];body[j+1]=temp;}}}}}}class Body {public int num;public String time;public int timer;boolean isMy=false;public Body(int num,String time){this.num=num;this.time=time;func(time);}public Body(){}private void func(String time2) {String[] str=time2.split(":");int h=Integer.parseInt(str[0]);int m=Integer.parseInt(str[1]);int s=Integer.parseInt(str[2]);this.timer=h*60*60+m*60+s;}}

版权声明:本文为博主原创文章,未经博主允许不得转载。

一个今天胜过两个明天

hdu1177(Accepted today?)

相关文章:

  • 【算法】直接插入排序C语言实现
  • 嵌入式 FAAC1.28 在海思HI3518C/HI3518A平台linux中的编译优化
  • Android 动画animation 深入分析
  • 你感兴趣的文章:

    标签云:

    亚洲高清电影在线, 免费高清电影, 八戒影院夜间, 八戒电影最新大片, 出轨在线电影, 午夜电影院, 在线影院a1166, 在线电影院, 在线观看美剧下载, 日本爱情电影, 日韩高清电影在线, 电影天堂网, 直播盒子app, 聚合直播, 高清美剧, 高清美剧在线观看 EhViewer-E站, E站, E站绿色版, qqmulu.com, qq目录网, qq网站目录,