結果
問題 | No.771 しおり |
ユーザー | McGregorsh |
提出日時 | 2023-07-06 12:53:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,686 ms / 2,000 ms |
コード長 | 1,767 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 193,408 KB |
最終ジャッジ日時 | 2024-07-20 08:05:19 |
合計ジャッジ時間 | 25,211 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,519 ms
193,280 KB |
testcase_01 | AC | 297 ms
100,224 KB |
testcase_02 | AC | 143 ms
88,320 KB |
testcase_03 | AC | 143 ms
88,320 KB |
testcase_04 | AC | 146 ms
88,320 KB |
testcase_05 | AC | 143 ms
88,192 KB |
testcase_06 | AC | 141 ms
88,320 KB |
testcase_07 | AC | 136 ms
88,192 KB |
testcase_08 | AC | 163 ms
89,216 KB |
testcase_09 | AC | 141 ms
88,192 KB |
testcase_10 | AC | 138 ms
88,192 KB |
testcase_11 | AC | 146 ms
88,192 KB |
testcase_12 | AC | 148 ms
88,192 KB |
testcase_13 | AC | 143 ms
88,192 KB |
testcase_14 | AC | 175 ms
89,344 KB |
testcase_15 | AC | 151 ms
88,192 KB |
testcase_16 | AC | 142 ms
88,960 KB |
testcase_17 | AC | 162 ms
89,088 KB |
testcase_18 | AC | 139 ms
88,064 KB |
testcase_19 | AC | 144 ms
88,704 KB |
testcase_20 | AC | 143 ms
88,064 KB |
testcase_21 | AC | 152 ms
88,320 KB |
testcase_22 | AC | 147 ms
88,652 KB |
testcase_23 | AC | 148 ms
88,960 KB |
testcase_24 | AC | 159 ms
89,344 KB |
testcase_25 | AC | 780 ms
139,648 KB |
testcase_26 | AC | 183 ms
90,368 KB |
testcase_27 | AC | 292 ms
100,224 KB |
testcase_28 | AC | 514 ms
113,408 KB |
testcase_29 | AC | 302 ms
100,096 KB |
testcase_30 | AC | 1,470 ms
193,152 KB |
testcase_31 | AC | 1,673 ms
193,024 KB |
testcase_32 | AC | 218 ms
91,136 KB |
testcase_33 | AC | 1,686 ms
193,280 KB |
testcase_34 | AC | 1,439 ms
193,280 KB |
testcase_35 | AC | 193 ms
91,136 KB |
testcase_36 | AC | 174 ms
89,344 KB |
testcase_37 | AC | 172 ms
89,856 KB |
testcase_38 | AC | 205 ms
91,136 KB |
testcase_39 | AC | 176 ms
89,472 KB |
testcase_40 | AC | 776 ms
139,648 KB |
testcase_41 | AC | 1,641 ms
193,280 KB |
testcase_42 | AC | 1,580 ms
193,280 KB |
testcase_43 | AC | 310 ms
100,224 KB |
testcase_44 | AC | 1,577 ms
192,896 KB |
testcase_45 | AC | 1,536 ms
193,408 KB |
ソースコード
import sys from sys import stdin from fractions import Fraction import math from math import ceil, floor, sqrt, pi, factorial, gcd from copy import deepcopy from collections import Counter, deque, defaultdict from heapq import heapify, heappop, heappush from itertools import accumulate, product, combinations, combinations_with_replacement, permutations from bisect import bisect, bisect_left, bisect_right from functools import reduce, lru_cache from decimal import Decimal, getcontext, ROUND_HALF_UP def i_input(): return int(stdin.readline()) def i_map(): return map(int, stdin.readline().split()) def i_list(): return list(i_map()) def s_input(): return stdin.readline()[:-1] def s_map(): return s_input().split() def s_list(): return list(s_map()) def lcm(a, b): return a * b // gcd(a, b) def get_distance(x1, y1, x2, y2): d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) return d def rotate(table): n_fild = [] for x in zip(*table[::-1]): n_fild.append(x) return n_fild sys.setrecursionlimit(10 ** 7) INF = float('inf') MOD = 10 ** 9 + 7 MOD2 = 998244353 alpa = 'abcdefghijklmnopqrstuvwxyz' ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def main(): N = int(input()) AB = [i_list() for i in range(N)] dp = [[INF] * N for i in range(2**N)] for i in range(N): dp[1 << i][i] = 0 for i in range(2**N): for j in range(N): if not i & (1 << j) and i != 0: continue l, r = AB[j] amari = r - l for k in range(N): ll, rr = AB[k] if i & (1 << k): continue dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], max(dp[i][j], amari + ll)) print(min(dp[-1])) if __name__ == '__main__': main()