結果

問題 No.4 おもりと天秤
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-08-03 09:53:48
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 15,077 ms
コンパイル使用メモリ 168,052 KB
実行使用メモリ 187,144 KB
最終ジャッジ日時 2024-04-21 08:28:31
合計ジャッジ時間 16,593 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
30,464 KB
testcase_01 AC 53 ms
30,592 KB
testcase_02 AC 59 ms
30,592 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 57 ms
30,592 KB
testcase_07 WA -
testcase_08 AC 54 ms
30,576 KB
testcase_09 AC 57 ms
30,720 KB
testcase_10 WA -
testcase_11 AC 57 ms
30,844 KB
testcase_12 AC 59 ms
30,464 KB
testcase_13 AC 59 ms
30,564 KB
testcase_14 AC 57 ms
30,592 KB
testcase_15 AC 55 ms
30,704 KB
testcase_16 WA -
testcase_17 AC 56 ms
30,836 KB
testcase_18 AC 59 ms
30,720 KB
testcase_19 WA -
testcase_20 AC 58 ms
30,848 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (103 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var w = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var k = w.Sum();
            var c = true;
            if (k % 2 != 0)
            {
                Console.WriteLine("impossible");
            }
            else
            {
                var sum = new List<int>[n];
                sum[0] = new List<int> { 0, w[0] };
                for (var i = 1; i < n; i++)
                {
                    sum[i] = sum[i - 1].Select(x => x + w[i]).Where(x => x <= k / 2).ToList();
                    if (sum[i].Any(x => x == k / 2))
                    {
                        Console.WriteLine("possible");
                        c = false;
                        break;
                    }
                }
                if (c)
                {
                    Console.WriteLine("impossible");
                }
            }
        }
    }
}
0