結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-04-06 01:46:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 544 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 63,092 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 11:34:28 |
合計ジャッジ時間 | 1,417 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 1 WA * 29 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N; cin >> N; vector<int> V(N); for (int i = 0; i < N; i++) { cin >> V[i]; } int m = 0; int c = 0; if (N == 1) { m = V[0]; } else if (N == 2) { m += max(V[c], V[c+1]); } else { for (int i = 0; i < N-1; i++) { m += max(V[c], V[c+1]); if (V[c] > V[c+1]) c += 2; else c += 2+1; } } cout << m << endl; return 0; }