結果

問題 No.4 おもりと天秤
ユーザー HimatsubushinHimatsubushin
提出日時 2019-12-21 12:47:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 4,016 ms
コンパイル使用メモリ 104,388 KB
実行使用メモリ 23,796 KB
最終ジャッジ日時 2023-09-26 12:22:43
合計ジャッジ時間 4,680 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,580 KB
testcase_01 AC 60 ms
21,648 KB
testcase_02 AC 61 ms
23,708 KB
testcase_03 AC 60 ms
21,704 KB
testcase_04 AC 60 ms
21,712 KB
testcase_05 AC 62 ms
23,624 KB
testcase_06 AC 60 ms
21,672 KB
testcase_07 AC 61 ms
21,532 KB
testcase_08 AC 60 ms
23,620 KB
testcase_09 AC 63 ms
21,716 KB
testcase_10 AC 62 ms
21,740 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 62 ms
23,784 KB
testcase_14 WA -
testcase_15 AC 61 ms
21,728 KB
testcase_16 AC 60 ms
23,564 KB
testcase_17 AC 62 ms
21,796 KB
testcase_18 AC 61 ms
21,512 KB
testcase_19 AC 61 ms
21,716 KB
testcase_20 AC 61 ms
21,732 KB
testcase_21 AC 61 ms
23,644 KB
testcase_22 AC 62 ms
23,736 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.Linq;

namespace No004_おもりと天秤2
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] list = input.Select(int.Parse).ToArray();
            int sum = list.Sum();
            bool[] dp = new bool[sum + list.Max() + 1];

            if (sum % 2 == 1)
            {
                Console.WriteLine("impossible");
                return;
            }
            dp[0] = true;

            for (int i = 0; i < list.Length; i++)
            {
                for (int j = 0; j <= sum; j++)
                {
                    if (dp[j] == true)
                    {
                        dp[j + list[i]] = true;
                    }
                }
            }

            if (dp[sum / 2] == true)
                Console.WriteLine("possible");
            else
                Console.WriteLine("impossible");
        }
    }
}
0