結果

問題 No.37 遊園地のアトラクション
ユーザー ikdikd
提出日時 2016-10-04 23:25:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 675 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 54,612 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-05-01 12:36:49
合計ジャッジ時間 20,761 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
9,088 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 38 ms
5,376 KB
testcase_03 AC 104 ms
5,376 KB
testcase_04 AC 44 ms
5,376 KB
testcase_05 AC 17 ms
5,376 KB
testcase_06 AC 9 ms
5,376 KB
testcase_07 AC 4,177 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 TLE -
testcase_11 AC 1,527 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 605 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 826 ms
5,376 KB
testcase_17 AC 157 ms
5,376 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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];
      for(int k=0; k<=n; k++){
         ret=max(ret, rec(i+1, j-c[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);
   cout<< rec(0, T)<< endl;

   return 0;
}
0