結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2014-12-09 15:38:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 849 bytes |
| コンパイル時間 | 1,774 ms |
| コンパイル使用メモリ | 78,048 KB |
| 実行使用メモリ | 56,104 KB |
| 最終ジャッジ日時 | 2024-06-11 18:54:40 |
| 合計ジャッジ時間 | 6,289 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 4 WA * 23 |
ソースコード
import java.math.*;
import java.util.*;
public class Main {
static int dfs(int now){
if(dp[now]!=0) return dp[now];
int res=0;
for(int i=0;i<n;i++){
if(now-c[i]<0) continue;
kai[i]++;
res=Math.max(res,dfs(now-c[i])+(int)(v[i]/Math.pow(2,kai[i]-1)));
kai[i]--;
}
return dp[now]=res;
}
static int[] kai;
static int n;
static int[] c;
static int[] v;
static int[] dp;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
n = sc.nextInt();
dp=new int[t+1];
c=new int[n];
kai=new int[n];
v=new int[n];
for(int i=0;i<n;i++){
c[i]=sc.nextInt();
}
for(int i=0;i<n;i++){
v[i]=sc.nextInt();
}
System.out.println(dfs(t));
}
}
kou6839