結果

問題 No.45 回転寿司
ユーザー notetonous
提出日時 2017-08-03 20:18:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 361 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 56,540 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 20:31:20
合計ジャッジ時間 1,553 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int N;
  int a[1001],dp[1001];
  cin >> N;
  for(int i=1;i<=N;i++)cin >> a[i];
  dp[0]=0;
  dp[1]=a[1];
  for(int i=2;i<=N;i++){
    int Max=0;
    for(int j=1;j<i-1;j++){
      Max=max(Max,dp[j]);
    }
    dp[i]=Max+a[i];
  }
  cout << dp[N] << endl;
  return 0;
}
0