結果

問題 No.45 回転寿司
ユーザー n_knuu
提出日時 2015-10-29 15:29:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 708 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 157,540 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 12:27:53
合計ジャッジ時間 2,974 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int dp[1024];
int V[1024];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) cin >> V[i];
  REP(i, N) {
    int sushi = 0;
    for (int j = i - 1; j >= 0; j--) {
      sushi = max(sushi, dp[j]);
    }
    dp[i+1] = max(dp[i], sushi + V[i]);
  }
  cout << dp[N] << endl;
  return 0;
}
0