結果

問題 No.45 回転寿司
ユーザー J31831276
提出日時 2018-12-26 14:58:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 56,664 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 14:43:10
合計ジャッジ時間 1,551 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

#define ll long long

using namespace std;

int main(){

   int n;
   cin>>n;

   int V[1000];
   for(int i=0;i<n;++i) cin>>V[i];

   int MAX[1000];
   MAX[0]=V[0];
   if(n>1) MAX[1]=max(V[0],V[1]);
   for(int i=1;i<n;++i)  MAX[i]=max(MAX[i-1],MAX[i-2]+V[i]);
   
   cout<<MAX[n-1]<<endl;


   return 0;
}
0