Submission #32593


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
typedef struct{
int j,m,e,ans;
char name[21];
}stu;
int main(){
int n;
scanf("%d",&n);
stu s[n];
for(int i=0;i<n;i++){
scanf("%s %d %d %d",s[i].name,&s[i].j,&s[i].m,&s[i].e);
s[i].ans=s[i].j+s[i].m+s[i].e;
}
for(int i=0;i<n;i++){
for(int j=0;j<n-1-i;j++){
if(s[j].ans<s[j+1].ans){
stu temp=s[j];
s[j]=s[j+1];
s[j+1]=temp;
}else if(s[j].ans==s[j+1].ans){
int a=strlen(s[j].name);
int b=strlen(s[j+1].name);
int N=min(a,b);
for(int x=0;x<N;x++){
if(s[j].name[x]>s[j+1].name[x]){
stu temp=s[j];
s[j]=s[j+1];
s[j+1]=temp;
break;
}
}
}
}
}
for(int i=0;i<n;i++){
printf("%d %s %d\n",i+1,s[i].name,s[i].ans);
}
return 0;
}

ステータス

項目 データ
問題 0054 - てすと
ユーザー名 Zzz..ei1704..Zzz
投稿日時 2018-04-11 17:22:45
言語 C++
状態 Accepted
得点 2
ソースコード長 903 Byte
最大実行時間 38 ms
最大メモリ使用量 664 KB

セット

セット 得点 Cases
1 ALL 2 / 2 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 38 ms 480 KB
1
in2.txt AC 18 ms 456 KB
1
in3.txt AC 22 ms 556 KB
1
in4.txt AC 17 ms 664 KB
1
in5.txt AC 25 ms 512 KB
1