結果

問題 No.771 しおり
ユーザー McGregorshMcGregorsh
提出日時 2023-07-06 12:29:20
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,811 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 198,112 KB
最終ジャッジ日時 2023-10-10 07:52:54
合計ジャッジ時間 34,974 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,939 ms
196,204 KB
testcase_01 AC 452 ms
103,372 KB
testcase_02 AC 238 ms
90,200 KB
testcase_03 AC 238 ms
90,068 KB
testcase_04 AC 237 ms
90,164 KB
testcase_05 AC 236 ms
90,148 KB
testcase_06 AC 238 ms
90,188 KB
testcase_07 AC 241 ms
89,992 KB
testcase_08 AC 269 ms
91,924 KB
testcase_09 AC 237 ms
90,212 KB
testcase_10 AC 233 ms
90,060 KB
testcase_11 AC 238 ms
90,060 KB
testcase_12 AC 233 ms
90,212 KB
testcase_13 AC 254 ms
90,100 KB
testcase_14 AC 273 ms
92,228 KB
testcase_15 AC 241 ms
90,172 KB
testcase_16 AC 234 ms
90,396 KB
testcase_17 AC 254 ms
91,216 KB
testcase_18 AC 233 ms
90,208 KB
testcase_19 AC 236 ms
90,500 KB
testcase_20 AC 231 ms
89,964 KB
testcase_21 AC 236 ms
90,016 KB
testcase_22 AC 236 ms
90,748 KB
testcase_23 AC 243 ms
91,368 KB
testcase_24 AC 250 ms
91,224 KB
testcase_25 AC 1,053 ms
142,928 KB
testcase_26 AC 292 ms
93,236 KB
testcase_27 AC 434 ms
103,500 KB
testcase_28 AC 728 ms
116,436 KB
testcase_29 AC 443 ms
103,768 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 303 ms
94,764 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 315 ms
94,868 KB
testcase_36 AC 280 ms
93,052 KB
testcase_37 AC 285 ms
92,780 KB
testcase_38 AC 307 ms
94,920 KB
testcase_39 AC 279 ms
92,432 KB
testcase_40 AC 1,084 ms
142,908 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 442 ms
103,912 KB
testcase_44 AC 1,967 ms
196,440 KB
testcase_45 AC 1,928 ms
196,204 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):
   	  p = 2 ** i
   	  dp[p][i] = 0
   
   for i in range(2**N):
   	  for j in range(N):
   	  	  l, r = AB[j]
   	  	  amari = r - l
   	  	  p = 2 ** j
   	  	  if i | p == i:
   	  	  	  for k in range(N):
   	  	  	  	  ll, rr = AB[k]
   	  	  	  	  pp = 2 ** k
   	  	  	  	  nxt = i | pp
   	  	  	  	  if nxt != i:
   	  	  	  	  	  cost = max(amari + ll, dp[i][j])
   	  	  	  	  	  dp[nxt][k] = min(dp[nxt][k], cost)
   print(min(dp[-1]))
   
   
if __name__ == '__main__':
    main()














0