結果

問題 No.771 しおり
ユーザー tcltktcltk
提出日時 2021-05-19 11:04:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,388 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 140,956 KB
最終ジャッジ日時 2023-09-29 13:07:40
合計ジャッジ時間 23,296 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,308 ms
140,644 KB
testcase_01 AC 283 ms
90,128 KB
testcase_02 AC 176 ms
80,776 KB
testcase_03 AC 171 ms
80,952 KB
testcase_04 AC 174 ms
80,640 KB
testcase_05 AC 171 ms
80,712 KB
testcase_06 AC 168 ms
80,884 KB
testcase_07 AC 177 ms
80,620 KB
testcase_08 AC 189 ms
83,796 KB
testcase_09 AC 168 ms
80,884 KB
testcase_10 AC 171 ms
80,948 KB
testcase_11 AC 169 ms
80,860 KB
testcase_12 AC 177 ms
80,740 KB
testcase_13 AC 170 ms
80,800 KB
testcase_14 AC 201 ms
83,512 KB
testcase_15 AC 170 ms
80,884 KB
testcase_16 AC 172 ms
81,056 KB
testcase_17 AC 190 ms
83,616 KB
testcase_18 AC 171 ms
80,952 KB
testcase_19 AC 172 ms
81,068 KB
testcase_20 AC 166 ms
80,884 KB
testcase_21 AC 168 ms
80,544 KB
testcase_22 AC 172 ms
80,812 KB
testcase_23 AC 189 ms
83,796 KB
testcase_24 AC 187 ms
83,368 KB
testcase_25 AC 672 ms
111,796 KB
testcase_26 AC 209 ms
84,356 KB
testcase_27 AC 288 ms
89,956 KB
testcase_28 AC 468 ms
97,108 KB
testcase_29 AC 299 ms
90,400 KB
testcase_30 AC 1,318 ms
140,516 KB
testcase_31 AC 1,325 ms
140,676 KB
testcase_32 AC 203 ms
84,528 KB
testcase_33 AC 1,361 ms
140,064 KB
testcase_34 AC 1,326 ms
140,312 KB
testcase_35 AC 198 ms
84,428 KB
testcase_36 AC 187 ms
84,452 KB
testcase_37 AC 197 ms
84,540 KB
testcase_38 AC 215 ms
84,524 KB
testcase_39 AC 205 ms
84,160 KB
testcase_40 AC 626 ms
111,908 KB
testcase_41 AC 1,346 ms
140,356 KB
testcase_42 AC 1,308 ms
140,560 KB
testcase_43 AC 292 ms
90,248 KB
testcase_44 AC 1,388 ms
140,956 KB
testcase_45 AC 1,286 ms
140,364 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**6] * 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