結果

問題 No.4 おもりと天秤
ユーザー HimatsubushinHimatsubushin
提出日時 2019-12-18 16:07:52
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 970 bytes
コンパイル時間 1,881 ms
コンパイル使用メモリ 61,628 KB
実行使用メモリ 25,844 KB
最終ジャッジ日時 2023-09-20 18:34:21
合計ジャッジ時間 4,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,516 KB
testcase_01 AC 60 ms
23,488 KB
testcase_02 AC 61 ms
21,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 61 ms
19,604 KB
testcase_07 WA -
testcase_08 AC 60 ms
21,704 KB
testcase_09 AC 62 ms
21,476 KB
testcase_10 WA -
testcase_11 AC 62 ms
21,584 KB
testcase_12 AC 62 ms
21,640 KB
testcase_13 AC 62 ms
23,704 KB
testcase_14 AC 61 ms
21,612 KB
testcase_15 AC 63 ms
21,576 KB
testcase_16 WA -
testcase_17 AC 62 ms
23,712 KB
testcase_18 AC 63 ms
21,764 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Linq;

namespace No004_おもりと天秤
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] weight = input.Select(int.Parse).ToArray();
            int total = weight.Sum();
            int sum = 0;

            if (total % 2 != 0)
            {
                Console.WriteLine("impossible");
                return;
            }

            Array.Sort(weight);

            for (int i = 1; sum < total / 2; i++)
            {
                int[] w2 = new int[i + 1];

                Array.Copy(weight, w2, i);
                sum = w2.Sum();

                if (sum == total / 2)
                {
                    Console.WriteLine("possible");
                    return;
                }
            }

            Console.WriteLine("impossible");
            return;
        }
    }
}
0