Submission #51539
ソースコード
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 | #include<bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define all(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < n; ++i) #define reps(i, m, n) for (int i = m; i <= n; ++i) typedef long long ll; typedef vector< int > vi; typedef vector<ll> vl; typedef pair< int , int > pii; typedef pair<ll, ll> pll; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; struct Student { string name; ll japanese; ll math; ll english; ll sum; }; signed main() { cin.tie(0); ios::sync_with_stdio( false ); int n; cin >> n; Student man[314]; rep(i, n) { cin >> man[i].name >> man[i].japanese >> man[i].math >> man[i].english; man[i].sum = man[i].japanese + man[i].math + man[i].english; } int max; for ( int i = 0; i < n - 1; ++i) { max = i; for ( int j = i; j < n; ++j) { if ( man[max].sum < man[j].sum ) { max = j; } } swap(man[i].name, man[max].name); swap(man[i].japanese, man[max].japanese); swap(man[i].math, man[max].math); swap(man[i].english, man[max].english); swap(man[i].sum, man[max].sum); } rep(i, n) { cout << man[i].name << ' ' << man[i].japanese << ' ' << man[i].math << ' ' << man[i].english << ' ' << man[i].sum << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0941 - 中間テスト |
ユーザー名 | もけ |
投稿日時 | 2019-07-14 18:53:25 |
言語 | C++14 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 1335 Byte |
最大実行時間 | 35 ms |
最大メモリ使用量 | 680 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input001.txt | AC | 35 ms | 604 KB |
1
|
input002.txt | AC | 27 ms | 680 KB |
1
|
input003.txt | AC | 20 ms | 492 KB |
1
|
input004.txt | AC | 22 ms | 564 KB |
1
|
input005.txt | AC | 21 ms | 512 KB |
1
|