Submission #08639


ソースコード

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<iostream>
#include<string>
#include<cstdio>
using namespace std;
typedef struct{
string name;
int sum;
}student;
int main(){
int n,a,b,c;
string str;
cin >> n;
student test[n];
for(int i=0;i<n;i++){
cin >> test[i].name;
cin >> a >> b >> c;
test[i].sum=a+b+c;
}
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(test[j].sum<test[j+1].sum || test[j].sum==test[j+1].sum && test[j].name>test[j+1].name){
int temp;
temp=test[j].sum;
test[j].sum=test[j+1].sum;
test[j+1].sum=temp;
str=test[j].name;
test[j].name=test[j+1].name;
test[j+1].name=str;
}
}
}
for(int i=1;i<=n;i++){
cout << i << " " << test[i-1].name << " " << test[i-1].sum << endl;
}
return(0);
}

ステータス

項目 データ
問題 0054 - てすと
ユーザー名 ei1612
投稿日時 2016-08-17 11:44:17
言語 C++11
状態 Accepted
得点 2
ソースコード長 779 Byte
最大実行時間 41 ms
最大メモリ使用量 656 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 38 ms 476 KB
1
in2.txt AC 41 ms 460 KB
1
in3.txt AC 16 ms 440 KB
1
in4.txt AC 22 ms 548 KB
1
in5.txt AC 13 ms 656 KB
1