結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-11-24 05:30:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 329 ms |
| コンパイル使用メモリ | 34,136 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 10:57:10 |
| 合計ジャッジ時間 | 1,290 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d", V+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
int N;
int V[1000];
int dp[1000];
int main(){
scanf("%d", &N);
for(int i=0;i<N;i++){
scanf("%d", V+i);
}
dp[0] = V[0];
for(int i=1;i<N;i++){
dp[i] = V[i];
for(int j=0;j<i-1;j++){
dp[i] = std::max(dp[i], dp[j] + V[i]);
}
}
int res = 0;
for(int i=0;i<N;i++){res = std::max(res, dp[i]);}
printf("%d\n", res);
}
tottoripaper