結果

問題 No.4 おもりと天秤
コンテスト
ユーザー むらため
提出日時 2019-01-29 02:27:24
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 576 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,762 ms
コンパイル使用メモリ 68,452 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-22 10:30:00
合計ジャッジ時間 2,445 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #
raw source code

import sequtils,math
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': return
    result = 10 * result + k.ord - '0'.ord

let n = scan()
var W : array[101,int]
var dp : array[10001,bool]
var wSum = 0
for i in 0..<n:
  W[i] = scan()
  wSum += W[i]
if wSum mod 2 == 1 : quit "impossible",0
let m = wSum div 2
dp[0] = true
for wi in 0..<n:
  let w = W[wi]
  for i in countdown(m-w,0):
    if dp[i] : dp[i + w] = true
  if dp[m] : quit "possible",0
quit "impossible",0
0