結果

問題 No.771 しおり
ユーザー McGregorshMcGregorsh
提出日時 2023-07-06 12:53:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,715 ms / 2,000 ms
コード長 1,767 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 196,076 KB
最終ジャッジ日時 2023-09-27 14:03:17
合計ジャッジ時間 28,792 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,623 ms
196,076 KB
testcase_01 AC 372 ms
103,184 KB
testcase_02 AC 209 ms
89,876 KB
testcase_03 AC 211 ms
89,872 KB
testcase_04 AC 212 ms
89,852 KB
testcase_05 AC 203 ms
89,772 KB
testcase_06 AC 208 ms
90,076 KB
testcase_07 AC 220 ms
89,788 KB
testcase_08 AC 244 ms
92,124 KB
testcase_09 AC 212 ms
90,096 KB
testcase_10 AC 208 ms
89,960 KB
testcase_11 AC 208 ms
90,068 KB
testcase_12 AC 210 ms
89,796 KB
testcase_13 AC 209 ms
89,868 KB
testcase_14 AC 235 ms
92,000 KB
testcase_15 AC 207 ms
89,864 KB
testcase_16 AC 208 ms
90,500 KB
testcase_17 AC 223 ms
90,968 KB
testcase_18 AC 209 ms
89,872 KB
testcase_19 AC 208 ms
90,528 KB
testcase_20 AC 214 ms
89,872 KB
testcase_21 AC 216 ms
89,792 KB
testcase_22 AC 212 ms
90,496 KB
testcase_23 AC 224 ms
90,984 KB
testcase_24 AC 239 ms
90,884 KB
testcase_25 AC 846 ms
142,612 KB
testcase_26 AC 255 ms
92,864 KB
testcase_27 AC 371 ms
103,264 KB
testcase_28 AC 585 ms
116,208 KB
testcase_29 AC 370 ms
103,180 KB
testcase_30 AC 1,540 ms
196,012 KB
testcase_31 AC 1,703 ms
196,016 KB
testcase_32 AC 270 ms
93,248 KB
testcase_33 AC 1,715 ms
195,940 KB
testcase_34 AC 1,523 ms
196,076 KB
testcase_35 AC 267 ms
93,432 KB
testcase_36 AC 247 ms
92,528 KB
testcase_37 AC 246 ms
92,464 KB
testcase_38 AC 264 ms
93,024 KB
testcase_39 AC 243 ms
92,680 KB
testcase_40 AC 834 ms
143,004 KB
testcase_41 AC 1,664 ms
195,992 KB
testcase_42 AC 1,571 ms
195,724 KB
testcase_43 AC 384 ms
103,304 KB
testcase_44 AC 1,587 ms
195,996 KB
testcase_45 AC 1,535 ms
195,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()













0