結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2018-12-26 15:02:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 383 bytes |
コンパイル時間 | 722 ms |
コンパイル使用メモリ | 56,988 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 19:50:27 |
合計ジャッジ時間 | 2,203 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <algorithm> #include <cstdio> #include <string> #define ll long long using namespace std; int main(){ int n; cin>>n; int V[1001]; for(int i=0;i<n;++i) cin>>V[i]; int MAX[1001]; MAX[0]=V[0]; if(n>1) MAX[1]=max(V[0],V[1]); for(int i=2;i<n;++i) MAX[i]=max(MAX[i-1],MAX[i-2]+V[i]); cout<<MAX[n-1]<<endl; return 0; }