Submission #00871
ソースコード
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 | #include <bits/stdc++.h> using namespace std; int n, k, cnt = 0, ans = 0; typedef struct { int m, c; } Work; Work a[100000]; int main() { cin >> n >> k; for ( int i = 0; i < n; i++) { cin >> a[i].m >> a[i].c; } for ( int i = 0; i < n; i++) { for ( int j = i; j < n; j++) { if (a[i].c > a[j].c) { Work temp = a[i]; a[i] = a[j]; a[j] = temp; } else if (a[i].c == a[j].c) { if (a[i].m < a[j].m) { Work temp = a[i]; a[i] = a[j]; a[j] = temp; } } } } int i = 0; while (cnt < k) { if (i == n) { cnt = 0; break ; } while (a[i].m >= a[i].c) { a[i].m -= a[i].c; cnt++; ans += a[i].c; if (cnt == k) { break ; } } i++; } if (cnt == 0) { cout << "NA" << endl; } else { cout << ans << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0056 - カップ麺うめぇ!うますぎるっ!ズルルルルル! |
ユーザー名 | ei1439 |
投稿日時 | 2015-07-31 09:04:23 |
言語 | C++11 |
状態 | Accepted |
得点 | 35 |
ソースコード長 | 942 Byte |
最大実行時間 | 15 ms |
最大メモリ使用量 | 675 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 35 / 35 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
KappumenInput1.txt | AC | 14 ms | 608 KB |
1
|
KappumenInput2.txt | AC | 11 ms | 572 KB |
1
|
KappumenInput3.txt | AC | 10 ms | 544 KB |
1
|
KappumenInput4.txt | AC | 13 ms | 513 KB |
1
|
KappumenInput5.txt | AC | 10 ms | 618 KB |
1
|
KappumenInput6.txt | AC | 12 ms | 583 KB |
1
|
KappumenInput7.txt | AC | 14 ms | 675 KB |
1
|
KappumenInput8.txt | AC | 15 ms | 511 KB |
1
|
KappumenInput9.txt | AC | 13 ms | 591 KB |
1
|