結果

問題 No.771 しおり
ユーザー tcltktcltk
提出日時 2021-05-19 11:01:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,421 ms / 2,000 ms
コード長 1,029 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 140,832 KB
最終ジャッジ日時 2023-09-29 13:06:58
合計ジャッジ時間 23,425 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,258 ms
140,820 KB
testcase_01 AC 267 ms
90,372 KB
testcase_02 AC 161 ms
81,024 KB
testcase_03 AC 162 ms
80,952 KB
testcase_04 AC 164 ms
80,784 KB
testcase_05 AC 165 ms
80,964 KB
testcase_06 AC 164 ms
80,864 KB
testcase_07 AC 163 ms
80,920 KB
testcase_08 AC 191 ms
83,924 KB
testcase_09 AC 175 ms
80,980 KB
testcase_10 AC 163 ms
81,080 KB
testcase_11 AC 169 ms
81,028 KB
testcase_12 AC 173 ms
80,924 KB
testcase_13 AC 171 ms
80,984 KB
testcase_14 AC 198 ms
83,864 KB
testcase_15 AC 170 ms
80,804 KB
testcase_16 AC 174 ms
81,100 KB
testcase_17 AC 191 ms
83,840 KB
testcase_18 AC 167 ms
80,948 KB
testcase_19 AC 172 ms
81,064 KB
testcase_20 AC 171 ms
80,948 KB
testcase_21 AC 174 ms
80,952 KB
testcase_22 AC 186 ms
81,224 KB
testcase_23 AC 177 ms
83,780 KB
testcase_24 AC 187 ms
83,864 KB
testcase_25 AC 682 ms
111,672 KB
testcase_26 AC 198 ms
84,632 KB
testcase_27 AC 284 ms
90,260 KB
testcase_28 AC 448 ms
97,188 KB
testcase_29 AC 283 ms
90,280 KB
testcase_30 AC 1,330 ms
140,436 KB
testcase_31 AC 1,341 ms
140,448 KB
testcase_32 AC 216 ms
84,608 KB
testcase_33 AC 1,393 ms
140,612 KB
testcase_34 AC 1,342 ms
140,572 KB
testcase_35 AC 217 ms
84,616 KB
testcase_36 AC 199 ms
84,380 KB
testcase_37 AC 193 ms
84,564 KB
testcase_38 AC 213 ms
84,612 KB
testcase_39 AC 194 ms
84,524 KB
testcase_40 AC 648 ms
111,848 KB
testcase_41 AC 1,396 ms
140,260 KB
testcase_42 AC 1,328 ms
140,580 KB
testcase_43 AC 288 ms
90,548 KB
testcase_44 AC 1,421 ms
140,832 KB
testcase_45 AC 1,237 ms
140,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """3
# 1 4
# 2 4
# 3 4
# """
# sys.stdin = io.StringIO(_INPUT)


def main():
    N = int(input())
    A = [None for _ in range(N)]
    B = [None for _ in range(N)]
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    dp = [[10**10] * N for _ in range(1<<N)]
    for i in range(N):
        dp[1<<i][i] = 0

    for s in range(1<<N):
        for k in range(N):
            if not(s & (1<<k)):
                continue
            for i in range(N):
                if s & (1<<i):
                    continue
                v1 = max(dp[s][k], B[k] - A[k] + A[i])
                s1 = s | (1<<i)
                dp[s1][i] = min(dp[s1][i], v1)

    ans = min(dp[(1<<N)-1])
    print(ans)

if __name__ == '__main__':
    main()
0