結果

問題 No.37 遊園地のアトラクション
ユーザー ikdikd
提出日時 2016-10-05 00:23:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,228 ms / 5,000 ms
コード長 924 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 55,260 KB
実行使用メモリ 23,756 KB
最終ジャッジ日時 2024-04-18 19:52:56
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,680 KB
testcase_01 AC 25 ms
23,756 KB
testcase_02 AC 29 ms
23,680 KB
testcase_03 AC 28 ms
23,552 KB
testcase_04 AC 29 ms
23,552 KB
testcase_05 AC 29 ms
23,680 KB
testcase_06 AC 29 ms
23,680 KB
testcase_07 AC 64 ms
23,508 KB
testcase_08 AC 28 ms
23,680 KB
testcase_09 AC 28 ms
23,552 KB
testcase_10 AC 49 ms
23,552 KB
testcase_11 AC 46 ms
23,552 KB
testcase_12 AC 28 ms
23,680 KB
testcase_13 AC 32 ms
23,508 KB
testcase_14 AC 27 ms
23,552 KB
testcase_15 AC 27 ms
23,680 KB
testcase_16 AC 35 ms
23,636 KB
testcase_17 AC 30 ms
23,680 KB
testcase_18 AC 56 ms
23,632 KB
testcase_19 AC 27 ms
23,552 KB
testcase_20 AC 31 ms
23,552 KB
testcase_21 AC 27 ms
23,680 KB
testcase_22 AC 1,228 ms
23,680 KB
testcase_23 AC 26 ms
23,552 KB
testcase_24 AC 25 ms
23,512 KB
testcase_25 AC 27 ms
23,680 KB
testcase_26 AC 28 ms
23,552 KB
testcase_27 AC 28 ms
23,632 KB
testcase_28 AC 28 ms
23,680 KB
testcase_29 AC 29 ms
23,680 KB
testcase_30 AC 26 ms
23,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>

using namespace std;

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

/*
int calc(int v, int n){

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

   return ret;
}
*/

void make_mome(){

   for(int v=1; v<=500; v++){
      int s=v;
      mome[v][0]=0;
      for(int n=1; n<=10000; n++){
         mome[v][n]+=mome[v][n-1]+s;
         s/=2;
      }
   }
}

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];
      for(int k=0; k<=n; k++){
         ret=max(ret, rec(i+1, j-c[i]*k)+mome[v[i]][k]);//calc(v[i], k));
      }
   }

   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);
   make_mome();
   cout<< rec(0, T)<< endl;

   return 0;
}
0