結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2018-10-15 18:01:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 542 bytes |
コンパイル時間 | 2,321 ms |
コンパイル使用メモリ | 79,564 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 19:38:48 |
合計ジャッジ時間 | 2,466 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <queue> using namespace std; int main(){ int N; cin >> N; int V[N]; for(int i=0; i<N; i++){ cin >> V[i]; } vector<int> dp(2); for(int i=0; i<N; i++){ vector<int> dp2(2); // 食べなかった時 dp2[0] = max(dp[0], dp[1]); // 食べた時 dp2[1] = dp[0] +V[i]; dp = dp2; } cout << max(dp[0], dp[1]) << endl; }