結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2019-07-08 23:27:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 326 bytes |
コンパイル時間 | 558 ms |
コンパイル使用メモリ | 71,180 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-09 17:34:34 |
合計ジャッジ時間 | 1,527 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> V(N), dp(N); for (int& i : V) cin >> i; dp[0] = V[0]; if (1 != N) dp[1] = max(V[0], V[1]); for (int i = 2; i < N; ++i) dp[i] = max(V[i] + dp[i - 2], dp[i - 1]); cout << dp.back(); }