結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-12-21 12:47:28 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,015 bytes | 
| コンパイル時間 | 799 ms | 
| コンパイル使用メモリ | 110,340 KB | 
| 実行使用メモリ | 27,280 KB | 
| 最終ジャッジ日時 | 2024-07-19 06:52:26 | 
| 合計ジャッジ時間 | 2,336 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 WA * 3 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
namespace No004_おもりと天秤2
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] list = input.Select(int.Parse).ToArray();
            int sum = list.Sum();
            bool[] dp = new bool[sum + list.Max() + 1];
            if (sum % 2 == 1)
            {
                Console.WriteLine("impossible");
                return;
            }
            dp[0] = true;
            for (int i = 0; i < list.Length; i++)
            {
                for (int j = 0; j <= sum; j++)
                {
                    if (dp[j] == true)
                    {
                        dp[j + list[i]] = true;
                    }
                }
            }
            if (dp[sum / 2] == true)
                Console.WriteLine("possible");
            else
                Console.WriteLine("impossible");
        }
    }
}
            
            
            
        