結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
23,700 KB
testcase_01 AC 61 ms
21,824 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 62 ms
21,672 KB
testcase_06 WA -
testcase_07 AC 61 ms
21,700 KB
testcase_08 AC 60 ms
21,504 KB
testcase_09 AC 61 ms
21,780 KB
testcase_10 AC 62 ms
21,592 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 61 ms
21,788 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 63 ms
23,620 KB
testcase_20 AC 63 ms
23,752 KB
testcase_21 AC 62 ms
21,684 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