結果
問題 |
No.545 ママの大事な二人の子供
|
ユーザー |
![]() |
提出日時 | 2017-07-21 22:01:25 |
言語 | Nim (2.2.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 933 bytes |
コンパイル時間 | 3,525 ms |
コンパイル使用メモリ | 67,024 KB |
実行使用メモリ | 476,400 KB |
最終ジャッジ日時 | 2024-06-30 01:44:15 |
合計ジャッジ時間 | 8,611 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 TLE * 1 -- * 12 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 39) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'future' [UnusedImport]
ソースコード
import strutils, sequtils, algorithm, future {.warning[SmallLshouldNotBeUsed]: off.} when isMainModule: var n = stdin.readLine.parseInt m = n div 2 a = newSeq[int](n) b = newSeq[int](n) for i in 0..<n: var x = stdin.readLine.split.map(parseInt) a[i] = x[0] b[i] = x[1] var s = newSeq[int]() t = newSeq[int]() for i in 0..<(1 shl m): var (x, y) = (0, 0) for j in 0..<m: if ((i shr j) and 1) == 1: x += a[j] else: y += b[j] s.add(x - y) for i in 0..<(1 shl n - m): var (x, y) = (0, 0) for j in 0..<(n - m): if ((i shr j) and 1) == 1: x += a[m + j] else: y += b[m + j] t.add(x - y) t.sort(cmp) var u = newSeq[int]() for i in 0..<s.len: var idx = lowerBound(t, -s[i]) if idx < t.len: u.add abs(s[i] + t[idx]) if 0 < idx: u.add abs(s[i] + t[idx-1]) # echo u echo min(u)