結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2023-04-30 19:57:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 1,418 ms |
コンパイル使用メモリ | 171,720 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-19 09:37:57 |
合計ジャッジ時間 | 2,455 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define srep(i, s, n) for (int i=(s); i < (int)(n); i++) #define all(v) v.begin(), v.end() #define fore(i,x) for(auto i:x) #define pb push_back using vi=vector<int>; using vvi=vector<vi>; using vb=vector<bool>; using vvb=vector<vb>; using vs=vector<string>; using vll=vector<long long>; using vvll=vector<vll>; using vc=vector<char>; using vvc=vector<vc>; using ll=long long; void Yes(bool ok){ cout << (ok ? "Yes" : "No") << "\n";} int main(){ int N; cin >> N; vi V(N); rep(i,N) cin >> V.at(i); vvi dp(N+1,vi(2)); rep(i,N){ dp.at(i+1).at(0)=max(dp.at(i+1).at(0),dp.at(i).at(1)+V.at(i)); dp.at(i+1).at(1)=max(dp.at(i+1).at(1),max(dp.at(i).at(1),dp.at(i).at(0))); } int ans=max(dp.at(N).at(0),dp.at(N).at(1)); cout << ans << "\n"; }