結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2019-11-25 18:52:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 444 bytes |
コンパイル時間 | 920 ms |
コンパイル使用メモリ | 66,068 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 13:31:25 |
合計ジャッジ時間 | 2,118 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
// I SELL YOU...! #include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> using namespace std; typedef long long ll; typedef pair<ll,ll> P; signed main(){ ll n; cin >> n; ll v[n],dp[n+1][2]; fill(dp[0],dp[n+1],0); for(int i=0;i<n;i++){ cin >> v[i]; } for(int i=0;i<n;i++){ dp[i+1][0]=max(dp[i][0],dp[i][1]); dp[i+1][1]=dp[i][0]+v[i]; } cout << max(dp[n][0],dp[n][1])<<endl; }