結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2017-06-27 21:29:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 576 ms |
コンパイル使用メモリ | 73,464 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 16:31:50 |
合計ジャッジ時間 | 1,594 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<cstdio> #include <iostream> #include<algorithm> #include<string> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<set> #include<numeric> #define mod 1000000007; using namespace std; typedef long long ll; typedef pair<ll, ll> Pr; ll dp[1010]; ll v[1010]; int main() { int N; cin >> N; for (int i = 0; i < N; i++) cin >> v[i]; dp[0] = v[0]; dp[1] = max(v[0], v[1]); for (int i = 1; i < N; i++) { dp[i + 1] = max(dp[i],dp[i-1]+v[i+1]); } cout << dp[N] << endl; return 0; }