結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2019-12-21 11:56:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,112 bytes |
コンパイル時間 | 920 ms |
コンパイル使用メモリ | 105,088 KB |
実行使用メモリ | 19,328 KB |
最終ジャッジ日時 | 2024-07-19 05:19:10 |
合計ジャッジ時間 | 2,584 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 11 |
コンパイルメッセージ
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 void Main() { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] list = input.Select(int.Parse).ToArray(); int sum = list.Sum(); int[,] a = new int[3, 6]; bool[,] dp = new bool[101, 10001]; if (sum % 2 == 1) { Console.WriteLine("impossible"); return; } dp[0, 0] = true; for (int i = 0; i < list.Length; i++) { for (int j = 0; j <= 20; j++) { if (dp[i, j] == true) { dp[i + 1, j + list[i]] = true; dp[i + 1, j] = true; } } } if (dp[list.Length, sum / 2] == true) Console.WriteLine("possible"); else Console.WriteLine("impossible"); } } }