結果

問題 No.4 おもりと天秤
ユーザー mencottonmencotton
提出日時 2017-12-25 21:08:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 880 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 102,572 KB
実行使用メモリ 31,424 KB
最終ジャッジ日時 2023-09-08 17:37:51
合計ジャッジ時間 4,982 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,720 KB
testcase_01 AC 61 ms
19,612 KB
testcase_02 AC 65 ms
21,724 KB
testcase_03 AC 63 ms
22,188 KB
testcase_04 AC 65 ms
21,692 KB
testcase_05 AC 100 ms
29,320 KB
testcase_06 AC 60 ms
23,760 KB
testcase_07 AC 100 ms
29,568 KB
testcase_08 AC 99 ms
27,412 KB
testcase_09 AC 98 ms
29,584 KB
testcase_10 AC 100 ms
29,324 KB
testcase_11 AC 63 ms
21,792 KB
testcase_12 AC 60 ms
23,600 KB
testcase_13 AC 60 ms
21,708 KB
testcase_14 AC 59 ms
21,644 KB
testcase_15 AC 61 ms
21,796 KB
testcase_16 AC 62 ms
21,868 KB
testcase_17 AC 62 ms
21,800 KB
testcase_18 AC 100 ms
29,472 KB
testcase_19 AC 100 ms
27,352 KB
testcase_20 AC 99 ms
29,304 KB
testcase_21 AC 99 ms
31,424 KB
testcase_22 AC 99 ms
29,464 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Text;
using System.Threading.Tasks;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool[,] dp = new bool[n, 100000];
            dp[0, 50000 + x[0]] = true; dp[0, 50000 - x[0]] = true;
            for (int i = 1; i < n; i++)
            {
                for (int j = 0; j < 100000; j++)
                {
                    if (dp[i - 1, j])
                    {
                        dp[i, j + x[i]] = true;
                        dp[i, j - x[i]] = true;
                    }
                }
            }
            Console.WriteLine(dp[n - 1, 50000] ? "possible" : "impossible");
        }
    }
}
0