結果
| 問題 |
No.268 ラッピング(Easy)
|
| コンテスト | |
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2015-08-21 22:51:11 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 5,000 ms |
| コード長 | 1,241 bytes |
| コンパイル時間 | 3,713 ms |
| コンパイル使用メモリ | 80,392 KB |
| 実行使用メモリ | 41,848 KB |
| 最終ジャッジ日時 | 2024-07-18 11:52:21 |
| 合計ジャッジ時間 | 6,172 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
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));}
}
t8m8⛄️