結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-21 11:57:09 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 1,115 bytes |
| コンパイル時間 | 814 ms |
| コンパイル使用メモリ | 105,856 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-07-19 05:20:24 |
| 合計ジャッジ時間 | 2,586 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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 <= 10000; 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");
}
}
}