結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-07-17 17:21:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 414 bytes |
コンパイル時間 | 840 ms |
コンパイル使用メモリ | 56,160 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 14:56:08 |
合計ジャッジ時間 | 1,593 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d",&e); | ~~~~~^~~~~~~~~
ソースコード
#include <iostream> #include<algorithm> #include<stdio.h> using namespace std; int dp[1001]={0}; int f(int p){ if(p<0)return 0; return dp[p]; } int main() { // your code goes here int n; scanf("%d",&n); for(int i=0;i<n;i++){ int e; scanf("%d",&e); dp[i]=e; dp[i]=std::max(dp[i],f(i-1)); dp[i]=std::max(dp[i],f(i-2)+e); dp[i]=std::max(dp[i],f(i-3)+e); } printf("%d\n",dp[n-1]); return 0; }