結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2014-12-14 12:19:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 439 bytes |
コンパイル時間 | 562 ms |
コンパイル使用メモリ | 33,492 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 11:05:08 |
合計ジャッジ時間 | 1,753 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf( "%d", &N ); | ~~~~~^~~~~~~~~~~~ main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf( "%d", V+i ); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<algorithm> #define rep(i,a) for(int i=0;i<(a);++i) #define clr(a,v) memset((a),(v),sizeof(a)) const int MAX_N = 1000; int N, V[MAX_N]; int dp[MAX_N+1][2]; int main() { scanf( "%d", &N ); rep( i, N ) scanf( "%d", V+i ); rep( i, N ) { dp[i+1][0] = std::max( dp[i][0], dp[i][1] ); dp[i+1][1] = dp[i][0]+V[i]; } printf( "%d\n", std::max( dp[N][0], dp[N][1] ) ); return 0; }