結果

問題 No.771 しおり
ユーザー むらためむらため
提出日時 2019-01-30 03:41:21
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 69,912 KB
実行使用メモリ 5,132 KB
最終ジャッジ日時 2023-09-14 03:15:07
合計ジャッジ時間 7,800 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 321 ms
5,108 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 172 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 28 ms
4,376 KB
testcase_28 AC 62 ms
4,380 KB
testcase_29 AC 21 ms
4,380 KB
testcase_30 AC 289 ms
5,100 KB
testcase_31 AC 301 ms
5,064 KB
testcase_32 AC 8 ms
4,380 KB
testcase_33 AC 370 ms
5,116 KB
testcase_34 AC 311 ms
5,084 KB
testcase_35 AC 7 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 8 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 109 ms
4,380 KB
testcase_41 AC 280 ms
5,060 KB
testcase_42 AC 304 ms
5,116 KB
testcase_43 AC 27 ms
4,380 KB
testcase_44 AC 398 ms
5,100 KB
testcase_45 AC 177 ms
5,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)
template `^`(n:int) : int = (1 shl n)

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

let n = scan()
let AB = newSeqWith(n,(a:scan(),b:scan()))
let L = AB.mapIt(it.a)
let R = AB.mapIt(it.b-it.a)
const INF = 1e10.int
var dp = newSeqWith(^n,INF)
var ans = INF
proc solve(s:int,r:int,cost:int) =
  if s == ^n - 1 :
    ans .min= cost
    return
  if dp[s] <= cost : return
  dp[s] .min= cost
  for x in 0..<n:
    if (s and ^x) > 0 : continue
    if s == 0 : solve(s or ^x,R[x],0)
    else: solve(s or ^x,R[x],cost.max(L[x]+r))
solve(0,0,0)
echo ans
0