結果

問題 No.771 しおり
ユーザー むらためむらため
提出日時 2019-01-30 03:42:36
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 829 bytes
コンパイル時間 4,477 ms
コンパイル使用メモリ 69,564 KB
実行使用メモリ 5,100 KB
最終ジャッジ日時 2023-09-30 07:20:43
合計ジャッジ時間 7,628 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
4,988 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 70 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 12 ms
4,380 KB
testcase_28 AC 29 ms
4,380 KB
testcase_29 AC 17 ms
4,380 KB
testcase_30 AC 131 ms
5,052 KB
testcase_31 AC 112 ms
5,072 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 93 ms
5,048 KB
testcase_34 AC 138 ms
4,968 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,384 KB
testcase_38 AC 4 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 76 ms
4,376 KB
testcase_41 AC 143 ms
5,048 KB
testcase_42 AC 250 ms
5,052 KB
testcase_43 AC 9 ms
4,376 KB
testcase_44 AC 141 ms
5,032 KB
testcase_45 AC 45 ms
5,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,algorithm
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())).sortedByIt(-it.a)
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