結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-03 15:35:34 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,224 bytes |
| コンパイル時間 | 15,912 ms |
| コンパイル使用メモリ | 166,896 KB |
| 実行使用メモリ | 188,536 KB |
| 最終ジャッジ日時 | 2024-10-13 12:23:42 |
| 合計ジャッジ時間 | 18,459 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 2 RE * 1 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (89 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
namespace yukicoder
{
public class Program
{
public static void Main()
{
var n = int.Parse(Console.ReadLine());
var w = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var k = w.Sum();
var c = new bool[n, k / 2 + 1];
c[0, 0] = true;
c[0, w[0]] = true;
if (k % 2 != 0)
{
Console.WriteLine("impossible");
}
else
{
for (var i = 1; i < n; i++)
{
for(var j = 0; j <= k / 2 ; j++)
{
if (c[i - 1, j] && j + w[i] <= k / 2 )
{
c[i, j + w[i]] = true;
c[i, j] = true;
}
}
}
if (c[n - 1, k / 2])
{
Console.WriteLine("possible");
}
else
{
Console.WriteLine("impossible");
}
}
}
}
}