結果
問題 | No.45 回転寿司 |
ユーザー |
|
提出日時 | 2016-10-18 20:33:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 765 ms |
コンパイル使用メモリ | 70,144 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 15:25:45 |
合計ジャッジ時間 | 1,671 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream>#include <vector>#include <deque>#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))typedef long long ll;using namespace std;int main() {int n; cin >> n;vector<int> v(n); repeat (i,n) cin >> v[i];vector<int> dp(n+1);dp[0] = 0;dp[1] = v[0];repeat_from (i,1,n) {dp[i+1] = max(dp[i], dp[i-1] + v[i]);}cout << dp[n] << endl;return 0;}