結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー YamyukiYamyuki
提出日時 2016-11-20 13:43:28
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 2,139 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 26,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 04:15:30
合計ジャッジ時間 2,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 28 ms
4,380 KB
testcase_06 AC 27 ms
4,376 KB
testcase_07 AC 13 ms
4,376 KB
testcase_08 AC 16 ms
4,376 KB
testcase_09 AC 39 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 29 ms
4,376 KB
testcase_14 AC 43 ms
4,380 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 38 ms
4,376 KB
testcase_20 AC 42 ms
4,380 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 9 ms
4,376 KB
testcase_24 AC 23 ms
4,376 KB
testcase_25 AC 34 ms
4,376 KB
testcase_26 AC 13 ms
4,376 KB
testcase_27 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>

int main(){
  int n,l[26],t,i,j,player,id,ac[26],score[4000][27],sort[4000],pp,h;
  char name[4001][17],p;
  
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&l[i]);
  	ac[i]=0;
  }
  scanf("%d",&t);
  player=0;
  for(i=0;i<t;i++){
  	j=-1;
  	getchar();
  	do{
  	j++;
  	scanf("%c",&name[0][j]);
  	}while(name[0][j]!=' ');
  	name[0][j]='\0';
  	if(player==0){
  		strcpy(name[1],name[0]);
  		player++;
  		scanf("%c",&p);
  		for(pp=0;pp<n+1;pp++){
  			score[0][pp]=0;
  		}
  		pp=0;
  		while(pp<25){
  				if(p=='A'+('B'-'A')*pp){
  					break;
  				}
  				pp++;
  			}
  		ac[pp]++;
  		score[0][pp]=50*l[pp]+(250*l[pp]/(4+ac[pp]));
  		score[0][n]=score[0][pp];
  		sort[0]=0;
  	}else{
  		id=0;
  		for(j=1;j<=player;j++){
  			if(strcmp(name[0],name[j])==0){
  				id=j;
  				j=player;
  			}
  		}
  		if(id==0){
  			player++;
  			strcpy(name[player],name[0]);
  			scanf("%c",&p);
  			for(pp=0;pp<n+1;pp++){
  			score[player-1][pp]=0;
  			}
  			pp=0;
  			while(pp<25){
  				if(p=='A'+('B'-'A')*pp){
  					break;
  				}
  				pp++;
  			}
  			ac[pp]++;
  			score[player-1][pp]=50*l[pp]+(250*l[pp]/(4+ac[pp]));
  			score[player-1][n]=score[player-1][pp];
  			sort[player-1]=player-1;
  			pp=player-1;
  			while(pp>0){
  				if(score[sort[pp-1]][n]<score[sort[pp]][n]){
  					h=sort[pp];
  					sort[pp]=sort[pp-1];
  					sort[pp-1]=h;
  				}else{
  					pp=1;
  				}
  				pp--;
  			}
  		}else{
  			scanf("%c",&p);
  			pp=0;
  			while(pp<25){
  				if(p=='A'+('B'-'A')*pp){
  					break;
  				}
  				pp++;
  			}
  			ac[pp]++;
  			score[id-1][pp]=50*l[pp]+(250*l[pp]/(4+ac[pp]));
  			score[id-1][n]+=score[id-1][pp];
  			pp=0;
  			while(sort[pp]!=id-1){
  				pp++;
  			}
  			while(pp>0){
  				if(score[sort[pp-1]][n]<score[sort[pp]][n]){
  					h=sort[pp];
  					sort[pp]=sort[pp-1];
  					sort[pp-1]=h;
  				}else{
  					pp=1;
  				}
  				pp--;
  			}
  		}
  	}
  }
  
  for(i=0;i<player;i++){
  	printf("%d %s",i+1,name[sort[i]+1]);
  	for(j=0;j<=n;j++){
  		printf(" %d",score[sort[i]][j]);
  	}
  	printf("\n");
  }
  return 0;
}
0