"Accepted today?"
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2351 Accepted Submission(s): 1052
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?〃儿
A test case starting with 0 0 0 0 0 terminates input and this test case should not to be processed.
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.
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
const int MAXN = 131;
int N,M;
int G, S, C;
struct node{
int n,a, b, c;
}nd[MAXN];
void jspl(){
int cnt[MAXN];
int w[MAXN];
int r[MAXN];
int getc[MAXN];
int num = 0;
int i, j;
while (num < 4){ //要排四层
memset(cnt, 0, sizeof(cnt));
if (num == 0){ //第一层
for (i = 0; i < N; i++){
w[i] = nd[i].c;
}
}
else if (num == 1){//第二层
for (i = 0; i < N; i++){
w[i] = nd[getc[N-1-i]].b; //要从大到小放,这样才能从小到大放
r[i]=getc[N-1-i]; //标记下排第N-1-i个是getc[N-1-i](原队列序号)
}
}
else if (num == 2){//第三层
for (i = 0; i < N; i++){
w[i] = nd[getc[N-1-i]].a;
r[i]=getc[N-1-i];
}
}
else if (num == 3){//第四层
for (i = 0; i < N; i++){
w[i] = nd[getc[N-1-i]].n;
r[i]=getc[N-1-i];
}
}
for (i = 0; i < N; i++){
cnt[w[i]]++;
}
if(num==2){
for (i = 1; i < 25; i++){//注意
cnt[i] += cnt[i - 1];//从小到大
}
}else if(num==3){
for(i=6;i>=0;i--){
cnt[i] += cnt[i + 1];//从大到小
}
}else{
for (i = 1; i < 60; i++){
cnt[i] += cnt[i - 1];//从小到大
}
}
if(num==0){
for (i = 0; i < N; i++){
//printf("%d ",cnt[w[i]]);
getc[--cnt[w[i]]] = i;//getc表示排在哪的是谁(序号标记)
}
}else{
for (i = 0; i < N; i++){
//printf("%d ",r[i]);
getc[--cnt[w[i]]] =r[i];
}
}
/*
for(i=0;i<N;i++){
printf("%d ",getc[i]);
}
printf("\n");
*/
num++;
}
S=S+G;
C=C+S;
M--;
for (i = 0; i < N; i++){
if(getc[i]==M){
if(1<=(i+1)&&(i+1)<=G){
printf("Accepted today? I've got a golden medal :)\n");
}else if((i+1)>G&&i+1<=S){
printf("Accepted today? I've got a silver medal :)\n");
}else if((i+1)>S&&i+1<=C){
printf("Accepted today? I've got a copper medal :)\n");
}else
printf("Accepted today? I've got an honor mentioned :)\n");
break;
}
// printf("%d ", getc[i]);
}
}
int main(){
int i, j;
int n,a, b, c;
freopen("in.txt", "r", stdin);
while (~scanf("%d%d%d%d%d", &N, &G, &S, &C, &M) && N&&G&&S&&C&&M){
char a1, a2;
char b1, b2;
char c1, c2;
for (i = 0; i < N; i++){
scanf("%d %c%c:%c%c:%c%c", &n, &a1,&a2, &b1,&b2, &c1,&c2);
a = (a1 - '0') * 10 + a2 - '0';
b = (b1 - '0') * 10 + b2 - '0';
c = (c1 - '0') * 10 + c2 - '0';
nd[i].n = n-1; //这里要n-1
nd[i].a = a;
nd[i].b = b;
nd[i].c = c;
// printf("%d %d %d\n",a,b,c);
}
jspl();
}
return 0;
}