Submission #00219
ソースコード
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 86 | #include<bits/stdc++.h> #define OUTPUT(n) cout << n << endl using namespace std; int n; int p[5001]; bool check(); int main(){ cin >> n; int cnt = 0; for ( int i=0;i<n;i++)cin >> p[i]; while (1){ int maxn = 0,idx; for ( int i=0;i<n;i++){ if (maxn <= p[i]){ maxn = p[i]; idx = i; } } // cout << p[0] << " " << p[1] << " " << p[2] << endl; // cout << idx << endl; if (idx == 0){ if (p[idx+1] == 0){ cnt += p[idx]; p[idx] = 0; } else { cnt += p[0]*2; p[0] = 0; p[1] = 0; } } else if (idx == n-1){ if (p[idx-1] == 0){ cnt += p[idx]; p[idx] = 0; } else { cnt += p[n-1]*2; p[n-1] = 0; p[n-2] = 0; } } else { //010 020 030 111 121 131 222 232 333 if (p[idx-1] == p[idx+1] && p[idx] != 0){ cnt+=2; p[idx-1]--; p[idx]--; if (p[idx-1] < 0)p[idx-1] = 0; } // 332 221 110 else if (p[idx] == p[idx-1] && p[idx]-1 == p[idx+1]){ cnt += 2; p[idx]--; p[idx-1]--; } //231 120 else if ((p[idx] == p[idx-1]+1 && p[idx] == p[idx+1]+2) || p[idx] == 3){ cnt += 2; p[idx]--; p[idx-1]--; } //132 021 else if (p[idx] == p[idx+1]+1 && p[idx] == p[idx-1]+2){ cnt += 2; p[idx]--; p[idx+1]--; } } if (check()) break ; } cout << cnt << endl; } bool check(){ bool ret = true ; for ( int i=0;i<n;i++){ if (p[i] > 0){ ret = false ; break ; } } return ret; } |
ステータス
項目 | データ |
---|---|
問題 | 0006 - パンケーキの焼き上がり |
ユーザー名 | 爆裂AUO |
投稿日時 | 2017-09-06 18:54:52 |
言語 | C++11 |
状態 | Time Limit Exceeded |
得点 | 0 |
ソースコード長 | 1538 Byte |
最大実行時間 | 1000 ms |
最大メモリ使用量 | 684 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 10 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 16 ms | 480 KB |
1
|
in02.txt | AC | 19 ms | 456 KB |
1
|
in03.txt | AC | 19 ms | 304 KB |
1
|
in04.txt | AC | 13 ms | 528 KB |
1
|
in05.txt | TLE | 1000 ms | 368 KB |
1
|
in06.txt | AC | 14 ms | 476 KB |
1
|
in07.txt | AC | 19 ms | 448 KB |
1
|
in08.txt | WA | 17 ms | 552 KB |
1
|
in09.txt | TLE | 1000 ms | 392 KB |
1
|
in10.txt | WA | 15 ms | 496 KB |
1
|
in11.txt | WA | 14 ms | 464 KB |
1
|
in12.txt | AC | 19 ms | 432 KB |
1
|
in13.txt | AC | 20 ms | 532 KB |
1
|
in14.txt | WA | 13 ms | 504 KB |
1
|
in15.txt | AC | 18 ms | 476 KB |
1
|
in16.txt | WA | 21 ms | 448 KB |
1
|
in17.txt | WA | 19 ms | 420 KB |
1
|
in18.txt | TLE | 1000 ms | 392 KB |
1
|
in19.txt | TLE | 1000 ms | 624 KB |
1
|
in20.txt | TLE | 1000 ms | 600 KB |
1
|
in21.txt | TLE | 1000 ms | 576 KB |
1
|
in22.txt | TLE | 1000 ms | 684 KB |
1
|
in23.txt | AC | 18 ms | 520 KB |
1
|
in24.txt | TLE | 1000 ms | 480 KB |
1
|
in25.txt | TLE | 1000 ms | 564 KB |
1
|
in26.txt | AC | 21 ms | 396 KB |
1
|
in27.txt | TLE | 1000 ms | 484 KB |
1
|
in28.txt | AC | 22 ms | 568 KB |
1
|
in29.txt | AC | 51 ms | 524 KB |
1
|
in30.txt | AC | 53 ms | 616 KB |
1
|