結果

問題 No.771 しおり
ユーザー Shuz*Shuz*
提出日時 2018-12-08 17:58:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,454 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 154,604 KB
最終ジャッジ日時 2023-11-10 05:24:25
合計ジャッジ時間 20,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,449 ms
154,476 KB
testcase_01 AC 172 ms
83,448 KB
testcase_02 AC 35 ms
53,332 KB
testcase_03 AC 36 ms
53,332 KB
testcase_04 AC 37 ms
53,332 KB
testcase_05 AC 37 ms
53,332 KB
testcase_06 AC 36 ms
53,332 KB
testcase_07 AC 36 ms
53,332 KB
testcase_08 AC 61 ms
68,480 KB
testcase_09 AC 36 ms
53,332 KB
testcase_10 AC 36 ms
53,332 KB
testcase_11 AC 36 ms
53,332 KB
testcase_12 AC 36 ms
53,332 KB
testcase_13 AC 37 ms
53,332 KB
testcase_14 AC 63 ms
68,472 KB
testcase_15 AC 36 ms
53,332 KB
testcase_16 AC 41 ms
59,320 KB
testcase_17 AC 58 ms
66,396 KB
testcase_18 AC 37 ms
53,332 KB
testcase_19 AC 40 ms
59,320 KB
testcase_20 AC 37 ms
53,332 KB
testcase_21 AC 37 ms
53,332 KB
testcase_22 AC 41 ms
59,320 KB
testcase_23 AC 49 ms
62,212 KB
testcase_24 AC 59 ms
66,396 KB
testcase_25 AC 620 ms
115,016 KB
testcase_26 AC 71 ms
72,632 KB
testcase_27 AC 178 ms
83,448 KB
testcase_28 AC 351 ms
90,996 KB
testcase_29 AC 179 ms
83,576 KB
testcase_30 AC 1,398 ms
154,476 KB
testcase_31 AC 1,417 ms
154,476 KB
testcase_32 AC 90 ms
77,220 KB
testcase_33 AC 1,454 ms
154,476 KB
testcase_34 AC 1,434 ms
154,476 KB
testcase_35 AC 91 ms
77,220 KB
testcase_36 AC 65 ms
70,580 KB
testcase_37 AC 66 ms
70,584 KB
testcase_38 AC 85 ms
74,148 KB
testcase_39 AC 66 ms
70,580 KB
testcase_40 AC 564 ms
115,016 KB
testcase_41 AC 1,386 ms
154,604 KB
testcase_42 AC 1,370 ms
154,600 KB
testcase_43 AC 177 ms
83,448 KB
testcase_44 AC 1,424 ms
154,604 KB
testcase_45 AC 1,310 ms
154,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 100000
MAX_N = 20
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b - a)
DP = []
for i in range(1 << N):
    DP.append([])
    for j in range(N):
        DP[i].append(INF)
for i in range(1 << N):
    for j in range(N):
        if i & (1 << j):
            for k in range(N):
                if not i & (1 << k):
                    new_max = (B[j] + A[k]) if DP[i][j] == INF else max(DP[i][j], B[j] + A[k])
                    new_bit = i | (1 << k)
                    DP[new_bit][k] = min(DP[new_bit][k], new_max)
res = INF
for i in range(N):
    res = min(res, DP[(1 << N) - 1][i])
print(res)
0