結果

問題 No.4 おもりと天秤
ユーザー stady0shstady0sh
提出日時 2017-06-08 13:08:42
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 110,564 KB
実行使用メモリ 25,404 KB
最終ジャッジ日時 2023-10-23 19:45:10
合計ジャッジ時間 2,498 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
25,400 KB
testcase_01 AC 28 ms
25,248 KB
testcase_02 AC 31 ms
25,404 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 30 ms
25,404 KB
testcase_06 AC 30 ms
25,400 KB
testcase_07 AC 30 ms
25,404 KB
testcase_08 AC 28 ms
25,248 KB
testcase_09 AC 31 ms
25,404 KB
testcase_10 AC 31 ms
25,404 KB
testcase_11 AC 30 ms
25,404 KB
testcase_12 AC 30 ms
25,400 KB
testcase_13 AC 30 ms
25,400 KB
testcase_14 AC 30 ms
25,404 KB
testcase_15 AC 30 ms
25,400 KB
testcase_16 AC 30 ms
25,404 KB
testcase_17 WA -
testcase_18 AC 30 ms
25,404 KB
testcase_19 AC 30 ms
25,404 KB
testcase_20 AC 30 ms
25,404 KB
testcase_21 AC 30 ms
25,404 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YukiCoder_Cs
{
    class Program
    {
        public static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] list = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            
            string ans = "possible";
            if (list.Sum()% 2 != 0)
            {
                ans = "impossible";
            }
            else
            {
                int a = 0;
                int b = 0;
                Array.Sort(list);
                Array.Reverse(list);
                foreach (var item in list)
                {
                    if (a > b)
                    {
                        b += item;
                    }
                    else
                    {
                        a += item;
                    }
                }

                if (a != b)
                {
                    ans = "impossible";
                }
            }
            Console.WriteLine(ans);
        }
    }
}
0