結果

問題 No.158 奇妙なお使い
ユーザー htensaihtensai
提出日時 2020-05-14 14:48:44
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 960 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 73,672 KB
実行使用メモリ 61,332 KB
最終ジャッジ日時 2023-10-13 09:48:18
合計ジャッジ時間 10,538 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
59,736 KB
testcase_01 AC 150 ms
55,808 KB
testcase_02 AC 150 ms
58,412 KB
testcase_03 AC 121 ms
55,976 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
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 #

import java.util.*;

public class Main {
    static int[] aArr = new int[4];
    static int[] bArr = new int[4];
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		for (int i = 0; i < 4; i++) {
		    aArr[i] = sc.nextInt();
		}
		for (int i = 0; i < 4; i++) {
		    bArr[i] = sc.nextInt();
		}
		System.out.println(func(a, b, c));
	}
	
	static int func(int a, int b, int c) {
	    return Math.max(func(a, b, c, aArr), func(a, b, c, bArr));
	}
	
	static int func(int a, int b, int c, int[] arr) {
	    if (a * 1000 + b * 100 + c < arr[0]) {
	        return 0;
	    }
	    int x = arr[0];
	    while (x >= 1000 && a > 0) {
	        x -= 1000;
	        a--;
	    }
	    while (x >= 100 && b > 0) {
	        x -= 100;
	        b--;
	    }
	    c -= x;
	    if (c < 0) {
	        return 0;
	    }
	    return func(a + arr[1], b + arr[2], c + arr[3]) + 1;
	}
}
0