結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-29 02:27:24 |
| 言語 | Nim (2.2.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 576 bytes |
| コンパイル時間 | 2,184 ms |
| コンパイル使用メモリ | 60,880 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-01 11:05:55 |
| 合計ジャッジ時間 | 2,939 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 23 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'math' [UnusedImport]
ソースコード
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