結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2019-05-06 00:34:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 389 bytes |
コンパイル時間 | 1,574 ms |
コンパイル使用メモリ | 158,940 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 20:33:57 |
合計ジャッジ時間 | 2,618 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v.at(i); int taken = v.at(0), nottaken = 0; for (int i = 1; i < n; i++) { int taken_new = nottaken + v.at(i); nottaken = max(taken, nottaken); taken = taken_new; } cout << max(taken, nottaken) << endl; }