結果

問題 No.4 おもりと天秤
ユーザー skewesskewes
提出日時 2015-12-29 15:03:12
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 901 bytes
コンパイル時間 1,318 ms
コンパイル使用メモリ 110,296 KB
実行使用メモリ 24,124 KB
最終ジャッジ日時 2023-10-19 12:20:25
合計ジャッジ時間 2,840 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,116 KB
testcase_01 AC 26 ms
24,116 KB
testcase_02 AC 25 ms
24,116 KB
testcase_03 AC 26 ms
24,116 KB
testcase_04 AC 26 ms
24,116 KB
testcase_05 AC 28 ms
24,120 KB
testcase_06 AC 26 ms
24,116 KB
testcase_07 AC 28 ms
24,120 KB
testcase_08 AC 28 ms
24,116 KB
testcase_09 RE -
testcase_10 AC 28 ms
24,124 KB
testcase_11 AC 26 ms
24,116 KB
testcase_12 AC 25 ms
24,116 KB
testcase_13 AC 26 ms
24,116 KB
testcase_14 AC 25 ms
24,116 KB
testcase_15 AC 26 ms
24,116 KB
testcase_16 AC 26 ms
24,116 KB
testcase_17 AC 26 ms
24,116 KB
testcase_18 AC 28 ms
24,120 KB
testcase_19 AC 27 ms
24,120 KB
testcase_20 AC 27 ms
24,120 KB
testcase_21 AC 27 ms
24,120 KB
testcase_22 AC 28 ms
24,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class _004
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] wn = Array.ConvertAll(Console.ReadLine().Split(' ')
                , x => int.Parse(x));

            bool[] s = new bool[n * 100];
            s[0] = true;

            int sum = 0;
            foreach (int w in wn)
            {
                sum += w;
                for (int i = n * 100 - 1; i >= 0; i--)
                {
                    if(s[i])
                    {
                        s[i + w] = true;
                    }
                }
            }

            if(sum % 2 == 0 && s[sum/2])
            {
                Console.WriteLine("possible");
            }
            else
            {
                Console.WriteLine("impossible");
            }
            Console.ReadLine();
        }
    }
}
0