結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-20 17:05:03 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 853 bytes |
| コンパイル時間 | 893 ms |
| コンパイル使用メモリ | 114,268 KB |
| 実行使用メモリ | 31,132 KB |
| 最終ジャッジ日時 | 2024-09-19 00:28:24 |
| 合計ジャッジ時間 | 10,684 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main() {
string[] d = Console.ReadLine().Split(' ');
int N = int.Parse(d[0]);
var da = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
if (da.Sum(x => x) % 2 != 0) {
Console.WriteLine("impossible");
return;
}
int m = da.Sum(x => x) / 2;
var dp = new bool[10000];
dp[0] = true;
for (int i = 0; i < N; i++) {
for (int j = m; j >= da[i]; j--) {
Console.WriteLine(dp[j - da[i]]);
dp[j] |= dp[j - da[i]];
}
}
if (dp[m]) {
Console.WriteLine("possible");
}
else {
Console.WriteLine("impossible");
}
}
}