結果

問題 No.4 おもりと天秤
ユーザー DAZYDAZY
提出日時 2017-05-22 15:16:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 594 bytes
コンパイル時間 3,617 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 57,896 KB
最終ジャッジ日時 2023-10-19 13:38:17
合計ジャッジ時間 8,092 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,376 KB
testcase_01 AC 137 ms
57,628 KB
testcase_02 AC 135 ms
57,648 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 144 ms
57,784 KB
testcase_06 AC 136 ms
57,616 KB
testcase_07 AC 142 ms
57,896 KB
testcase_08 AC 143 ms
57,588 KB
testcase_09 AC 153 ms
55,840 KB
testcase_10 AC 143 ms
57,264 KB
testcase_11 AC 140 ms
57,560 KB
testcase_12 AC 133 ms
57,764 KB
testcase_13 AC 134 ms
57,632 KB
testcase_14 AC 135 ms
57,572 KB
testcase_15 AC 136 ms
57,360 KB
testcase_16 AC 133 ms
55,464 KB
testcase_17 WA -
testcase_18 AC 149 ms
57,772 KB
testcase_19 AC 149 ms
57,820 KB
testcase_20 AC 145 ms
57,784 KB
testcase_21 AC 146 ms
57,832 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class No4 {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int W[] = new int[N];
        for (int i = 0; i < N; i++) W[i] = scan.nextInt();
        Arrays.sort(W);
        int left = W[N-1], right = W[N-2];
        for (int i = N-3; i >= 0; i--) {
            if (left > right) right += W[i];
            else left += W[i];
        }
        if (left == right) System.out.println("possible");
        else  System.out.println("impossible");
    }
}
0