結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
vrjfsyi
|
| 提出日時 | 2018-03-24 23:20:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 539 bytes |
| コンパイル時間 | 1,293 ms |
| コンパイル使用メモリ | 68,348 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 18:43:21 |
| 合計ジャッジ時間 | 2,011 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <map>
#include <stack>
#include <queue>
#include <set>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> v(N);
int n;
for (int i = 0; i < N; ++i) {
cin >> n;
v[i] = n;
}
vector<int> dp(N + 2);
dp[0] = 0;
dp[1] = 0;
for (int j = 2; j < N + 2; ++j) {
dp[j] = max(dp[j - 2] + v[j - 2], dp[j - 1]);
}
cout << dp[N + 1] << "\n";
return 0;
}
vrjfsyi