結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-24 06:33:00 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,259 bytes |
| コンパイル時間 | 17,849 ms |
| コンパイル使用メモリ | 172,828 KB |
| 実行使用メモリ | 195,284 KB |
| 最終ジャッジ日時 | 2025-09-24 06:33:22 |
| 合計ジャッジ時間 | 20,922 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 2 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (98 ミリ秒)。 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.Linq;
using System.Text;
using System.Collections.Generic;
using STR = System.String;
using INT = System.Int64;
using DEC = System.Double;
using BOOL = System.Boolean;
class Program
{
public static IO IO = new IO();
static void Main(string[] args)
{
INT n = IO.I();
INT[] w = IO.I(' ');
INT total = w.Sum();
BOOL[,] dp = new BOOL[n + 1, 10001];
dp[0, 0] = true;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 10001; j++)
{
if (dp[i, j])
{
dp[i + 1, j + w[i]] = true;
dp[i + 1, j] = true;
}
}
}
IO.W(dp[n, total / 2] ? "possible" : "impossible");
IO.F();
}
}
public class IO
{
private const int WMAX = 1000;
private StringBuilder SB = new StringBuilder();
private T R<T>(Func<STR, T> f) { return f(Console.ReadLine()); }
private T[] R<T>(Func<STR, T> f, char c) { return S().Split(c).Select(f).ToArray(); }
private T[] R<T>(Func<STR, T> f, INT l) { T[] r = new T[l]; for (INT i = 0; i < l; i++) { r[i] = R(f); } return r; }
private T[][] R<T>(Func<STR, T> f, INT l, char c) { T[][] r = new T[l][]; for (INT i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
private void W<T>(Func<T, STR> f, T v, bool lf = true) { SB.Append(f(v)); if (lf) { SB.Append('\n'); } if (SB.Length >= WMAX) { F(); } }
public STR S() { return R(s => s); }
public STR[] S(char c) { return R(s => s, c); }
public STR[] S(INT l) { return R(s => s, l); }
public STR[][] S(INT l, char c) { return R(s => s, l, c); }
public INT I() { return R(INT.Parse); }
public INT[] I(char c) { return R(INT.Parse, c); }
public INT[] I(INT l) { return R(INT.Parse, l); }
public INT[][] I(INT l, char c) { return R(INT.Parse, l, c); }
public DEC D() { return R(DEC.Parse); }
public DEC[] D(char c) { return R(DEC.Parse, c); }
public DEC[] D(INT l) { return R(DEC.Parse, l); }
public DEC[][] D(INT l, char c) { return R(DEC.Parse, l, c); }
public void W(object s, bool lf = true) { W(v => v.ToString(), s, lf); }
public void F() { Console.Write(SB); SB.Length = 0; }
}