結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2019-08-09 21:48:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 782 bytes |
コンパイル時間 | 1,595 ms |
コンパイル使用メモリ | 173,220 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-19 11:36:32 |
合計ジャッジ時間 | 2,659 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 WA * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #ifndef __MACRO_H__ #define __MACRO_H__ #define all(collection) (collection).begin(), (collection).end() // begin to end #define rep(i, begin, end) for (ll i = begin; i < end; i++) // repeat #define repr(i, begin, end) for (ll i = begin; end < i; i--) // repeat reverse #endif int main(void) { ll n; cin >> n; // 最大で3つ前から取ってくるので、空要素を3つ追加 n += 3; vector<ll> v(n); rep(i, 3, n) cin >> v[i]; vector<vector<ll>> dp(n, vector<ll>(2)); rep(i, 3, n) { rep(j, 0, 2) dp[i][j] = max(*max_element(all(dp[i-2])) + v[i], *max_element(all(dp[i-3])) + v[i]); } cout << *max_element(all(dp.back())) << endl; return 0; }