結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-01-23 12:27:05 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,056 bytes | 
| コンパイル時間 | 875 ms | 
| コンパイル使用メモリ | 112,160 KB | 
| 実行使用メモリ | 27,424 KB | 
| 最終ジャッジ日時 | 2024-09-16 04:21:29 | 
| 合計ジャッジ時間 | 2,277 ms | 
| ジャッジサーバーID (参考情報) | judge6 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 WA * 7 | 
コンパイルメッセージ
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_おもりと天秤
{
    class Program
    {
        static private int N;
        static private int[] W;
        static private int AllSum;
        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            W = input.Select(int.Parse).ToArray();
            AllSum = 0;
            foreach (int a in W)
                AllSum += a;
            for (int i = 0; i < N; i++)
                Count(i, 0);
            Count(0, 0);
            if (AllSum == -1)
                Console.WriteLine("possible");
            else
                Console.WriteLine("impossible");
        }
        static void Count(int level, int sum)
        {
            sum += W[level];
            if (AllSum - sum == sum)
            {
                AllSum = -1;
            }
            else if (AllSum != -1 && level < N - 1)
            {
                Count(level + 1, sum);
            }
        }
    }
}
            
            
            
        