結果

問題 No.4 おもりと天秤
ユーザー aoyan5652aoyan5652
提出日時 2019-10-31 18:04:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 102,600 KB
実行使用メモリ 23,892 KB
最終ジャッジ日時 2023-10-13 00:08:24
合計ジャッジ時間 4,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,684 KB
testcase_01 AC 62 ms
23,604 KB
testcase_02 AC 62 ms
21,680 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 62 ms
23,892 KB
testcase_06 AC 63 ms
21,588 KB
testcase_07 AC 62 ms
21,796 KB
testcase_08 AC 62 ms
23,664 KB
testcase_09 AC 62 ms
21,576 KB
testcase_10 AC 62 ms
23,792 KB
testcase_11 AC 61 ms
21,836 KB
testcase_12 AC 61 ms
21,632 KB
testcase_13 AC 61 ms
21,624 KB
testcase_14 AC 61 ms
19,624 KB
testcase_15 AC 61 ms
19,604 KB
testcase_16 AC 60 ms
21,560 KB
testcase_17 WA -
testcase_18 AC 63 ms
23,536 KB
testcase_19 AC 61 ms
23,652 KB
testcase_20 AC 61 ms
23,492 KB
testcase_21 AC 61 ms
21,496 KB
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 _19._10._31._4
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(a);

            if (a.Sum() % 2 == 0 && n > 1)
            {
                int sum1 = a[n - 1]; int sum2 = a[n - 2];
                for (int i = n - 3; i >= 0; i--)
                {
                    if (sum1 < sum2)
                        sum1 += a[i];
                    else
                        sum2 += a[i];
                }
                if (sum1 == sum2)
                { Console.WriteLine("possible"); return; }
            }
            Console.WriteLine("impossible");
        }
    }
}
0