結果
問題 | No.268 ラッピング(Easy) |
ユーザー | uafr_cs |
提出日時 | 2015-08-21 22:36:25 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 1,511 bytes |
コンパイル時間 | 2,140 ms |
コンパイル使用メモリ | 76,352 KB |
実行使用メモリ | 56,352 KB |
最終ジャッジ日時 | 2023-09-25 14:56:42 |
合計ジャッジ時間 | 4,591 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
56,132 KB |
testcase_01 | AC | 123 ms
55,980 KB |
testcase_02 | AC | 123 ms
56,300 KB |
testcase_03 | AC | 124 ms
55,956 KB |
testcase_04 | AC | 126 ms
56,224 KB |
testcase_05 | AC | 123 ms
55,884 KB |
testcase_06 | AC | 122 ms
55,928 KB |
testcase_07 | AC | 123 ms
56,236 KB |
testcase_08 | AC | 122 ms
56,124 KB |
testcase_09 | AC | 123 ms
55,556 KB |
testcase_10 | AC | 123 ms
56,104 KB |
testcase_11 | AC | 122 ms
55,828 KB |
testcase_12 | AC | 123 ms
56,352 KB |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static <T> void swap(T[] array, int fst, int snd){ T tmp = array[fst]; array[fst] = array[snd]; array[snd] = tmp; } public static <T> void reverse(T[] array, int begin, int end){ // [begin, end) for(int i = begin, j = end - 1; i < j; i++, j--) { swap(array, i, j); } } @SafeVarargs public static <T extends Comparable<? super T>> boolean next_permutation(T ... perm) { for(int i = perm.length - 1; i > 0; i--){ if(perm[i - 1].compareTo(perm[i]) < 0){ int j = perm.length; while(perm[i - 1].compareTo(perm[--j]) >= 0); swap(perm, i - 1, j); reverse(perm, i, perm.length); // [i, n) return true; } } reverse(perm, 0, perm.length); // [0, n) return false; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); Integer[] lens = {sc.nextInt(), sc.nextInt(), sc.nextInt()}; Arrays.sort(lens); final int R = sc.nextInt(); final int B = sc.nextInt(); final int Y = sc.nextInt(); int min = Integer.MAX_VALUE; do{ final int red = (lens[0] * 2 + lens[2] * 2) * R; final int blue = (lens[0] * 2 + lens[1] * 2) * B; final int yellow = (lens[1] * 2 + lens[2] * 2) * Y; min = Math.min(min, red + blue + yellow); }while(next_permutation(lens)); System.out.println(min); } }