結果

問題 No.771 しおり
ユーザー McGregorshMcGregorsh
提出日時 2023-07-06 12:45:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,898 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 196,208 KB
最終ジャッジ日時 2023-09-27 13:56:21
合計ジャッジ時間 35,612 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 446 ms
103,436 KB
testcase_02 AC 243 ms
90,048 KB
testcase_03 AC 243 ms
90,012 KB
testcase_04 AC 243 ms
90,044 KB
testcase_05 AC 244 ms
90,016 KB
testcase_06 AC 246 ms
89,964 KB
testcase_07 AC 245 ms
89,880 KB
testcase_08 AC 273 ms
92,096 KB
testcase_09 AC 242 ms
90,004 KB
testcase_10 AC 244 ms
90,072 KB
testcase_11 AC 239 ms
89,828 KB
testcase_12 AC 240 ms
90,120 KB
testcase_13 AC 245 ms
89,892 KB
testcase_14 AC 272 ms
92,088 KB
testcase_15 AC 242 ms
89,868 KB
testcase_16 AC 248 ms
90,376 KB
testcase_17 AC 260 ms
90,952 KB
testcase_18 AC 242 ms
89,980 KB
testcase_19 AC 244 ms
90,676 KB
testcase_20 AC 246 ms
90,020 KB
testcase_21 AC 237 ms
90,128 KB
testcase_22 AC 243 ms
90,432 KB
testcase_23 AC 254 ms
90,912 KB
testcase_24 AC 257 ms
91,084 KB
testcase_25 AC 1,028 ms
142,912 KB
testcase_26 AC 295 ms
92,996 KB
testcase_27 AC 443 ms
103,532 KB
testcase_28 AC 744 ms
116,020 KB
testcase_29 AC 453 ms
103,376 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 306 ms
94,620 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 318 ms
94,736 KB
testcase_36 AC 291 ms
92,772 KB
testcase_37 AC 285 ms
92,732 KB
testcase_38 AC 317 ms
94,340 KB
testcase_39 AC 289 ms
92,480 KB
testcase_40 AC 1,070 ms
142,552 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 443 ms
103,140 KB
testcase_44 AC 1,996 ms
195,916 KB
testcase_45 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 = dp[i][j]
   	  	  	  	  	  if cost < amari + ll:
   	  	  	  	  	  	  cost = amari + ll
   	  	  	  	  	  if dp[nxt][k] > cost:
   	  	  	  	  	  	  dp[nxt][k] = cost
   print(min(dp[-1]))
   
   
if __name__ == '__main__':
    main()













0