結果

問題 No.268 ラッピング(Easy)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-21 22:51:11
言語 Java19
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 1,241 bytes
コンパイル時間 6,244 ms
コンパイル使用メモリ 75,840 KB
実行使用メモリ 56,344 KB
最終ジャッジ日時 2023-09-25 15:04:28
合計ジャッジ時間 6,499 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,040 KB
testcase_01 AC 127 ms
55,984 KB
testcase_02 AC 128 ms
55,876 KB
testcase_03 AC 127 ms
56,344 KB
testcase_04 AC 128 ms
55,912 KB
testcase_05 AC 125 ms
56,272 KB
testcase_06 AC 128 ms
56,072 KB
testcase_07 AC 128 ms
55,788 KB
testcase_08 AC 127 ms
55,976 KB
testcase_09 AC 127 ms
56,160 KB
testcase_10 AC 128 ms
55,672 KB
testcase_11 AC 128 ms
55,808 KB
testcase_12 AC 128 ms
55,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0268 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int l1 = in.nextInt();
		int l2 = in.nextInt();
		int l3 = in.nextInt();
		int r = in.nextInt();
		int b = in.nextInt();
		int y = in.nextInt();
		int[] a = {(l1 + l2)*2, (l2 + l3)*2, (l3 + l1)*2};
		int min = Integer.MAX_VALUE;
		Arrays.sort(a);
		do {
			min = Math.min(min, a[0]*r + a[1]*b + a[2]*y);
		}while (nextPermutation(a));
		out.println(min);
	}

	public static boolean nextPermutation(int[] a) {
		int n = a.length, i, j;
		for (i=n-2; i>=0 && a[i]>=a[i+1]; i--);
		if (i == -1) return false;
		for (j=i+1; j<n && a[i]<a[j]; j++);
		int tmp = a[i]; a[i] = a[j-1]; a[j-1] = tmp;
		for (int l=i+1, r=n-1; l<r; l++,r--) {
			tmp = a[l]; a[l] = a[r]; a[r] = tmp;
		}
		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0