結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2021-10-21 17:57:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 504 bytes |
コンパイル時間 | 4,520 ms |
コンパイル使用メモリ | 251,320 KB |
最終ジャッジ日時 | 2025-01-25 02:25:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000 int main(){ int n; cin>>n; vector<int> v(n); rep(i,n)cin>>v[i]; vector<int> dp(2,0); rep(i,n){ vector<int> ndp(2,0); rep(j,2)ndp[j] = max(ndp[j],dp[j]); ndp[0] = max(ndp[0],dp[1]); ndp[1] = max(ndp[1],dp[0]+v[i]); swap(dp,ndp); } cout<<max(dp[0],dp[1])<<endl; return 0; }