Submission #36762
ソースコード
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #include<iostream> #include<algorithm> #include<string> #include<vector> #include<queue> #include<map> #include<set> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; int n; struct student{ vector<string> name; vector< long long > jap, math, eng; vector< long long > total; student(){}; student( int n){ name.resize(n); jap.resize(n); math.resize(n); eng.resize(n); total.resize(n); } void in( int i){ cin >> name[i] >> jap[i] >> math[i] >> eng[i]; } void out( int i){ cout << name[i] << " " << jap[i] << " " << math[i] << " " << eng[i] << " " << total[i] << endl; } void sum( int i){ total[i] = jap[i] + math[i] + eng[i]; } void result(){ for ( int i=0;i<n;i++){ int mpos = i; for ( int j=i;j<n;j++){ if (total[j] > total[mpos]){ mpos = j; } } all_swap(i, mpos); } } void all_swap( int a, int b){ swap(name[a], name[b]); swap(jap[a], jap[b]); swap(math[a], math[b]); swap(eng[a], eng[b]); swap(total[a], total[b]); } }; int main(){ ios_base::sync_with_stdio( false ); cin >> n; student data(n); for ( int i=0;i<n;i++){ data.in(i); data.sum(i); } data.result(); for ( int i=0;i<n;i++){ data.out(i); } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0941 - 中間テスト |
ユーザー名 | Xyca. |
投稿日時 | 2018-06-04 20:21:11 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 1438 Byte |
最大実行時間 | 39 ms |
最大メモリ使用量 | 604 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input001.txt | AC | 31 ms | 476 KB |
1
|
input002.txt | AC | 24 ms | 540 KB |
1
|
input003.txt | AC | 39 ms | 604 KB |
1
|
input004.txt | AC | 22 ms | 540 KB |
1
|
input005.txt | AC | 25 ms | 476 KB |
1
|