結果
問題 | No.158 奇妙なお使い |
ユーザー | ぴろず |
提出日時 | 2015-02-27 00:09:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 997 ms / 5,000 ms |
コード長 | 1,281 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 73,900 KB |
実行使用メモリ | 137,088 KB |
最終ジャッジ日時 | 2023-09-11 07:52:31 |
合計ジャッジ時間 | 11,172 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 217 ms
135,440 KB |
testcase_01 | AC | 215 ms
132,740 KB |
testcase_02 | AC | 201 ms
134,092 KB |
testcase_03 | AC | 201 ms
134,336 KB |
testcase_04 | AC | 997 ms
135,832 KB |
testcase_05 | AC | 201 ms
134,648 KB |
testcase_06 | AC | 201 ms
134,132 KB |
testcase_07 | AC | 201 ms
134,312 KB |
testcase_08 | AC | 206 ms
134,092 KB |
testcase_09 | AC | 221 ms
135,552 KB |
testcase_10 | AC | 211 ms
134,608 KB |
testcase_11 | AC | 220 ms
135,804 KB |
testcase_12 | AC | 205 ms
134,144 KB |
testcase_13 | AC | 205 ms
132,212 KB |
testcase_14 | AC | 211 ms
134,660 KB |
testcase_15 | AC | 235 ms
135,504 KB |
testcase_16 | AC | 229 ms
135,312 KB |
testcase_17 | AC | 325 ms
135,404 KB |
testcase_18 | AC | 232 ms
135,756 KB |
testcase_19 | AC | 213 ms
134,660 KB |
testcase_20 | AC | 223 ms
135,916 KB |
testcase_21 | AC | 212 ms
135,276 KB |
testcase_22 | AC | 251 ms
137,088 KB |
testcase_23 | AC | 218 ms
135,264 KB |
testcase_24 | AC | 219 ms
135,284 KB |
testcase_25 | AC | 205 ms
134,164 KB |
testcase_26 | AC | 221 ms
135,488 KB |
testcase_27 | AC | 203 ms
134,704 KB |
testcase_28 | AC | 261 ms
134,696 KB |
testcase_29 | AC | 222 ms
135,552 KB |
testcase_30 | AC | 265 ms
134,828 KB |
ソースコード
package no158; import java.util.Arrays; import java.util.Scanner; public class Main { static int a1000; static int a100; static int a1; static int b1000; static int b100; static int b1; static int db; static int c1000; static int c100; static int c1; static int dc; static int[][][] dp = new int[15][110][10100]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); a1000 = sc.nextInt(); a100 = sc.nextInt(); a1 = sc.nextInt(); db = sc.nextInt(); b1000 = sc.nextInt(); b100 = sc.nextInt(); b1 = sc.nextInt(); dc = sc.nextInt(); c1000 = sc.nextInt(); c100 = sc.nextInt(); c1 = sc.nextInt(); for(int i=0;i<=10;i++) { for(int j=0;j<=100;j++) { Arrays.fill(dp[i][j], -1); } } System.out.println(dfs(a1000,a100,a1)); } public static int dfs(int a,int b,int c) { if (dp[a][b][c] >= 0) { return dp[a][b][c]; } int max = 0; for(int i=0;i<=a;i++) { for(int j=0;j<=b;j++) { int bx = db - i * 1000 - j * 100; if (bx >= 0 && bx <= c) { max = Math.max(max, dfs(a-i+b1000, b-j+b100, c-bx+b1) + 1); } int cx = dc - i * 1000 - j * 100; if (cx >= 0 && cx <= c) { max = Math.max(max, dfs(a-i+c1000, b-j+c100, c-cx+c1) + 1); } } } return dp[a][b][c] = max; } }