結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2022-12-23 06:40:11 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 3,546 ms |
コンパイル使用メモリ | 66,464 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 03:56:43 |
合計ジャッジ時間 | 4,609 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(3, 8) Warning: imported and not used: 'bitops' [UnusedImport]
ソースコード
import sequtils import strutils import bitops import math import deques proc get[T](s:seq[T],index :int):T= if index < 0 or s.len <= index: return false return s[index] var n = stdin.readLine.parseInt var a = stdin.readLine.split.map parseInt var half = (a.sum div 2) var DP = newSeqWith(n+1,newSeqWith(half+1,false)) DP[0][0] = true for i in 1..n: for j in 0..half: DP[i][j] = DP[i-1][j] or DP[i-1].get(j-a[i-1]) if a.sum mod 2 == 1: echo "impossible" else: echo if DP[n][half]:"possible"else:"impossible"