結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2024-09-27 14:08:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 2,648 ms |
コンパイル使用メモリ | 246,892 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 14:08:57 |
合計ジャッジ時間 | 3,571 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 WA * 7 |
ソースコード
#include <bits/stdc++.h> using i64 = long long; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); int n; std::cin >> n; std::vector<i64> a(n); for (auto &x : a) std::cin >> x; constexpr i64 inf = std::numeric_limits<i64>::max() >> 4; std::vector<i64> dp(n, -inf); dp[0] = a[0]; i64 max = -inf; for (int i = 1; i < n; ++i) { dp[i] = a[i]; if (i - 2 >= 0) { max = std::max(max, dp[i - 2]); dp[i] = std::max(dp[i], dp[i] + max); } } std::cout << dp[n - 1] << '\n'; return 0; }