結果

問題 No.4 おもりと天秤
ユーザー akichiakichi
提出日時 2017-08-18 02:39:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 588 bytes
コンパイル時間 3,096 ms
コンパイル使用メモリ 105,904 KB
実行使用メモリ 25,092 KB
最終ジャッジ日時 2023-09-08 17:33:47
合計ジャッジ時間 5,120 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
24,848 KB
testcase_01 AC 61 ms
24,900 KB
testcase_02 AC 65 ms
22,848 KB
testcase_03 AC 66 ms
24,732 KB
testcase_04 AC 68 ms
24,984 KB
testcase_05 AC 80 ms
24,604 KB
testcase_06 AC 65 ms
24,896 KB
testcase_07 AC 82 ms
24,912 KB
testcase_08 AC 61 ms
22,776 KB
testcase_09 AC 66 ms
22,904 KB
testcase_10 AC 83 ms
25,092 KB
testcase_11 AC 67 ms
22,832 KB
testcase_12 AC 66 ms
22,780 KB
testcase_13 AC 65 ms
22,784 KB
testcase_14 AC 65 ms
22,712 KB
testcase_15 AC 65 ms
22,784 KB
testcase_16 AC 66 ms
22,864 KB
testcase_17 AC 66 ms
22,784 KB
testcase_18 AC 74 ms
24,820 KB
testcase_19 AC 79 ms
24,384 KB
testcase_20 AC 79 ms
24,592 KB
testcase_21 AC 77 ms
24,184 KB
testcase_22 AC 80 ms
24,692 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
class Program {
    static void Main() {
        string ans = "impossible";
        Console.ReadLine();
        int[] ws = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int sum = ws.Sum();
        if (sum % 2 == 0) {
            HashSet<int> leftW = new HashSet<int> { 0 };

            foreach (int w in ws) {
                leftW.UnionWith(leftW.Select(x => x + w).ToArray());
            }
            if (leftW.Contains(sum / 2)) ans = "possible";
        }
        Console.WriteLine(ans);
    }
}
0