結果

問題 No.45 回転寿司
ユーザー n_knuu
提出日時 2015-10-29 15:32:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 590 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 157,156 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 12:29:26
合計ジャッジ時間 2,695 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:20:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |   REP(i, N) scanf("%d", V+i);
      |             ~~~~~^~~~~~~~~~~

ソースコード

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() {
  int N;
  scanf("%d", &N);
  REP(i, N) scanf("%d", V+i);
  int sushi = 0;
  REP(i, N) {
    dp[i+1] = max(dp[i], sushi + V[i]);
    sushi = max(sushi, dp[i]);
  }
  printf("%d\n", dp[N]);
  return 0;
}
0