結果
問題 | No.27 板の準備 |
ユーザー | Grenache |
提出日時 | 2016-03-12 12:07:20 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 135 ms / 5,000 ms |
コード長 | 1,412 bytes |
コンパイル時間 | 3,304 ms |
コンパイル使用メモリ | 79,672 KB |
実行使用メモリ | 56,396 KB |
最終ジャッジ日時 | 2023-08-27 04:24:57 |
合計ジャッジ時間 | 6,640 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
55,796 KB |
testcase_01 | AC | 122 ms
56,052 KB |
testcase_02 | AC | 124 ms
56,164 KB |
testcase_03 | AC | 118 ms
56,036 KB |
testcase_04 | AC | 129 ms
55,636 KB |
testcase_05 | AC | 120 ms
55,992 KB |
testcase_06 | AC | 131 ms
56,396 KB |
testcase_07 | AC | 131 ms
56,212 KB |
testcase_08 | AC | 134 ms
55,788 KB |
testcase_09 | AC | 135 ms
56,060 KB |
testcase_10 | AC | 130 ms
55,912 KB |
testcase_11 | AC | 133 ms
55,804 KB |
testcase_12 | AC | 134 ms
56,076 KB |
testcase_13 | AC | 128 ms
55,596 KB |
testcase_14 | AC | 123 ms
56,136 KB |
testcase_15 | AC | 132 ms
56,360 KB |
testcase_16 | AC | 122 ms
55,852 KB |
testcase_17 | AC | 131 ms
55,924 KB |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main_yukicoder27 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] v = new int[4]; for (int i = 0; i < 4; i++) { v[i] = sc.nextInt(); } Arrays.sort(v); int max = v[3]; int min = Integer.MAX_VALUE; for (int i = 1; i <= max; i++) { for (int j = i + 1; j <= max + 1; j++) { next: for (int k = j + 1; k <= max + 2; k++) { int sum = 0; for (int e : v) { int tmp = isOK(e, i, j, k, max); if (tmp == 0) { continue next; } sum += tmp; } min = Math.min(min, sum); } } } System.out.println(min); sc.close(); } private static int isOK(int v, int a, int b, int c, int max) { int min = Integer.MAX_VALUE; for (int i = v / c; i >= 0; i--) { for (int j = (v - c * i) / b; j >= 0; j--) { if ((v - c * i - b * j) % a == 0) { int k = (v - c * i - b * j) / a; if ((j != 0 && b > max) || (i != 0 && c > max)) { continue; } min = Math.min(min, i + j + k); } } } if (min == Integer.MAX_VALUE) { return 0; } else { return min; } } }