結果

問題 No.268 ラッピング(Easy)
ユーザー nCk_cvnCk_cv
提出日時 2015-08-21 22:45:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 823 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 74,196 KB
実行使用メモリ 56,288 KB
最終ジャッジ日時 2023-09-25 14:59:13
合計ジャッジ時間 4,525 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,624 KB
testcase_01 AC 123 ms
55,760 KB
testcase_02 AC 122 ms
55,700 KB
testcase_03 AC 122 ms
55,600 KB
testcase_04 AC 122 ms
55,516 KB
testcase_05 AC 125 ms
55,372 KB
testcase_06 AC 122 ms
55,812 KB
testcase_07 AC 123 ms
56,288 KB
testcase_08 AC 125 ms
55,572 KB
testcase_09 AC 121 ms
56,160 KB
testcase_10 AC 125 ms
55,760 KB
testcase_11 AC 123 ms
55,596 KB
testcase_12 AC 123 ms
54,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static int R;
	static int B;
	static int Y;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] l = new int[3];
		l[0] = sc.nextInt();
		l[1] = sc.nextInt();
		l[2] = sc.nextInt();
		R = sc.nextInt();
		B = sc.nextInt();
		Y = sc.nextInt();
		
		int min = check(l,new boolean[3],new int[3],0);
		System.out.println(min);
		
	}
	static int check(int[] a, boolean[] b, int[] c, int d) {
		if(d == 3) {
			return c[0] * 2 * R + c[2] * 2 * R + c[0] * 2 * B + c[1] * 2 * B + c[1] *2 * Y + c[2] * 2 * Y;
		}
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < 3; i++) {
			if(b[i]) continue;
			b[i] = true; c[d] = a[i];
			min = Math.min(check(a,b,c,d+1), min);
			b[i] = false; c[d] = 0;
		}
		return min;
	}
}
0