結果

問題 No.37 遊園地のアトラクション
ユーザー ikdikd
提出日時 2016-10-04 23:58:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,827 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 54,492 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 19:53:04
合計ジャッジ時間 3,356 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 54 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 35 ms
5,376 KB
testcase_11 AC 29 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 14 ms
5,376 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 45 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1,827 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>

using namespace std;

int T, N;
int c[10001], v[10001];
int memo[16][10001];

/*
int calc(int v, int n){
   int ret=0;
   for(int i=0; i<n; i++){
      ret+=v;
      v/=2;
   }

   return ret;
}
*/

int rec(int i, int j){

   if(memo[i][j]!=-1) return memo[i][j];
   int ret=0;
   if(i==N){
      ret=0;
   }else{
      int n=j/c[i];
      int V=v[i];
      int s=0;
      for(int k=0; k<=n; k++){
         if(k==0){
            ret=rec(i+1, j);
         }else{
            ret=max(ret, rec(i+1, j-c[i]*k)+s);//calc(v[i], k));
         }
         s+=V;
         V/=2;
      }
   }

   return memo[i][j]=ret;
}

int main(){

   cin>> T>> N;
   for(int i=0; i<N; i++) cin>> c[i];
   for(int i=0; i<N; i++) cin>> v[i];

   fill((int*)memo, (int*)memo+16*10001, -1);
   cout<< rec(0, T)<< endl;

   return 0;
}
0