結果

問題 No.158 奇妙なお使い
ユーザー ぴろずぴろず
提出日時 2015-05-15 14:06:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 995 ms / 5,000 ms
コード長 1,403 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 80,584 KB
実行使用メモリ 119,816 KB
最終ジャッジ日時 2023-09-07 22:44:01
合計ジャッジ時間 10,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 201 ms
118,256 KB
testcase_01 AC 201 ms
117,708 KB
testcase_02 AC 182 ms
117,864 KB
testcase_03 AC 178 ms
117,576 KB
testcase_04 AC 995 ms
119,440 KB
testcase_05 AC 182 ms
117,680 KB
testcase_06 AC 180 ms
118,076 KB
testcase_07 AC 181 ms
117,904 KB
testcase_08 AC 182 ms
117,688 KB
testcase_09 AC 199 ms
118,848 KB
testcase_10 AC 193 ms
117,800 KB
testcase_11 AC 199 ms
118,596 KB
testcase_12 AC 188 ms
117,888 KB
testcase_13 AC 182 ms
117,768 KB
testcase_14 AC 193 ms
118,184 KB
testcase_15 AC 216 ms
118,876 KB
testcase_16 AC 209 ms
118,476 KB
testcase_17 AC 290 ms
118,300 KB
testcase_18 AC 210 ms
118,552 KB
testcase_19 AC 192 ms
118,520 KB
testcase_20 AC 209 ms
118,688 KB
testcase_21 AC 193 ms
118,588 KB
testcase_22 AC 230 ms
119,816 KB
testcase_23 AC 199 ms
118,520 KB
testcase_24 AC 199 ms
118,648 KB
testcase_25 AC 180 ms
117,732 KB
testcase_26 AC 199 ms
118,772 KB
testcase_27 AC 180 ms
117,720 KB
testcase_28 AC 240 ms
118,012 KB
testcase_29 AC 199 ms
118,944 KB
testcase_30 AC 241 ms
118,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no158;

import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {

	public static void main(String[] args) {
		try {
			new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
		} catch (SecurityException e) {
			System.out.println("(◞‸◟)");
		}
	}

	int a1000,a100,a1,b1000,b100,b1,db,c1000,c100,c1,dc;
	int[][][] dp = new int[11][101][10001];
	public void run() {
		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));
		sc.close();
	}
	public int dfs(int a,int b,int c) {
		if (a < 0 || b < 0 || c < 0) {
			return 0; //苦し紛れ
		}
		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;
	}


}
0