結果
| 問題 |
No.268 ラッピング(Easy)
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2015-08-21 22:36:25 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 118 ms / 5,000 ms |
| コード長 | 1,511 bytes |
| コンパイル時間 | 2,077 ms |
| コンパイル使用メモリ | 79,796 KB |
| 実行使用メモリ | 41,920 KB |
| 最終ジャッジ日時 | 2024-07-18 11:45:24 |
| 合計ジャッジ時間 | 4,026 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
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);
}
}
uafr_cs