結果

問題 No.158 奇妙なお使い
ユーザー ぴろずぴろず
提出日時 2015-02-27 00:05:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,019 ms / 5,000 ms
コード長 1,281 bytes
コンパイル時間 2,529 ms
コンパイル使用メモリ 79,240 KB
実行使用メモリ 120,908 KB
最終ジャッジ日時 2023-09-11 07:52:19
合計ジャッジ時間 11,496 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 204 ms
118,940 KB
testcase_01 AC 204 ms
117,996 KB
testcase_02 AC 189 ms
117,784 KB
testcase_03 AC 191 ms
117,872 KB
testcase_04 AC 1,019 ms
119,584 KB
testcase_05 AC 190 ms
117,656 KB
testcase_06 AC 187 ms
117,436 KB
testcase_07 AC 200 ms
117,440 KB
testcase_08 AC 193 ms
117,548 KB
testcase_09 AC 215 ms
120,908 KB
testcase_10 AC 202 ms
117,808 KB
testcase_11 AC 205 ms
119,136 KB
testcase_12 AC 193 ms
117,692 KB
testcase_13 AC 186 ms
117,556 KB
testcase_14 AC 203 ms
118,136 KB
testcase_15 AC 224 ms
118,792 KB
testcase_16 AC 214 ms
119,020 KB
testcase_17 AC 313 ms
118,452 KB
testcase_18 AC 217 ms
118,772 KB
testcase_19 AC 195 ms
117,960 KB
testcase_20 AC 208 ms
119,024 KB
testcase_21 AC 198 ms
118,492 KB
testcase_22 AC 237 ms
119,608 KB
testcase_23 AC 206 ms
118,980 KB
testcase_24 AC 205 ms
118,736 KB
testcase_25 AC 193 ms
117,724 KB
testcase_26 AC 210 ms
118,928 KB
testcase_27 AC 187 ms
117,788 KB
testcase_28 AC 243 ms
118,304 KB
testcase_29 AC 210 ms
118,948 KB
testcase_30 AC 246 ms
117,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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[11][101][10001];
	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;
	}

}
0