結果

問題 No.45 回転寿司
ユーザー abinull
提出日時 2025-08-24 14:28:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 401 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 74,336 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-24 14:28:46
合計ジャッジ時間 2,199 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 1 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main() {

int n;
cin >> n;

vector<int> v(n);
vector<int> s(n, 0);

for (int i=0;i<n;i++) cin >> v[i];

s[0] = 0;
s[1] = max(v[0], v[1]);

for (int j=2;j<n;j++) {
    s[j] = max(s[j-1] + v[j-2], s[j-1]);
}

int res=0;

for (int i=0;i<n;i++) {
    res = max(res, s[i]);
}

cout << res << endl;

return 0;
}
0