結果
問題 | No.45 回転寿司 |
ユーザー |
![]() |
提出日時 | 2019-11-13 09:32:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 374 bytes |
コンパイル時間 | 2,178 ms |
コンパイル使用メモリ | 194,156 KB |
最終ジャッジ日時 | 2025-01-08 03:56:31 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n, 0), d(n, 0); for (int i = 0; i < n; i++) cin >> a[i]; d[0] = a[0]; d[1] = max(d[0], a[1]); for (int i = 2; i < n; i++) { d[i] = max(d[i-1], d[i-2] + a[i]); } cout << d[n-1] << endl; }