結果

問題 No.268 ラッピング(Easy)
ユーザー tentententen
提出日時 2020-11-18 09:05:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 924 bytes
コンパイル時間 3,224 ms
コンパイル使用メモリ 73,288 KB
実行使用メモリ 56,332 KB
最終ジャッジ日時 2023-09-30 14:50:55
合計ジャッジ時間 4,307 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,540 KB
testcase_01 AC 118 ms
56,332 KB
testcase_02 AC 117 ms
56,008 KB
testcase_03 AC 116 ms
56,116 KB
testcase_04 AC 116 ms
56,216 KB
testcase_05 AC 116 ms
55,852 KB
testcase_06 AC 117 ms
55,892 KB
testcase_07 AC 118 ms
55,808 KB
testcase_08 AC 119 ms
55,952 KB
testcase_09 AC 120 ms
55,812 KB
testcase_10 AC 122 ms
55,724 KB
testcase_11 AC 120 ms
56,064 KB
testcase_12 AC 119 ms
55,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] base = new int[3];
        for (int i = 0; i < 3; i++) {
            base[i] = sc.nextInt();
        }
        int[] lengths = new int[3];
        for (int i = 0; i < 3; i++) {
            lengths[i] = base[i] + base[(i + 1) % 3];
            lengths[i] *= 2;
        }
        int[] rgb = new int[3];
        for (int i = 0; i < 3; i++) {
            rgb[i] = sc.nextInt();
        }
        int[][] perm = new int[][]{{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
        int min = Integer.MAX_VALUE;
        for (int[] order : perm) {
            int sum = 0;
            for (int i = 0; i < 3; i++) {
                sum += lengths[i] * rgb[order[i]];
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
}
0