結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2017-06-29 16:48:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 363 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 56,828 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 16:32:17 |
合計ジャッジ時間 | 1,462 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; #define REP(i, N) for(int i=0;i<(N);++i) int main() { int n; cin >> n; int v[1000] = {}; REP(i, n) cin >> v[i]; int d[1000] = {}; d[0] = v[0]; d[1] = max(d[0], v[1]); for (int i = 2; i < n; ++i) { d[i] = max(d[i-1], d[i-2] + v[i]); } cout << d[n-1] << endl; }