結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  skewes | 
| 提出日時 | 2015-12-29 15:16:23 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 5,000 ms | 
| コード長 | 886 bytes | 
| コンパイル時間 | 1,768 ms | 
| コンパイル使用メモリ | 105,856 KB | 
| 実行使用メモリ | 18,176 KB | 
| 最終ジャッジ日時 | 2024-06-26 09:22:54 | 
| 合計ジャッジ時間 | 3,128 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
namespace yukicoder
{
    class _004
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] wn = Array.ConvertAll(Console.ReadLine().Split(' ')
                , x => int.Parse(x));
            bool[] s = new bool[n * 50 + 1];
            s[0] = true;
            int sum = 0;
            foreach (int w in wn)
            {
                sum += w;
                for (int i = n * 50; i >= 0; i--)
                {
                    if(s[i] && i + w <= n * 50)
                    {
                        s[i + w] = true;
                    }
                }
            }
            if(sum % 2 == 0 && s[sum/2])
            {
                Console.WriteLine("possible");
            }
            else
            {
                Console.WriteLine("impossible");
            }
        }
    }
}
            
            
            
        