結果
問題 | No.771 しおり |
ユーザー | McGregorsh |
提出日時 | 2023-07-06 12:29:20 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,811 bytes |
コンパイル時間 | 296 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 193,640 KB |
最終ジャッジ日時 | 2024-09-13 00:14:52 |
合計ジャッジ時間 | 30,163 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,860 ms
192,948 KB |
testcase_01 | AC | 345 ms
100,556 KB |
testcase_02 | AC | 141 ms
88,628 KB |
testcase_03 | AC | 143 ms
88,512 KB |
testcase_04 | AC | 142 ms
88,552 KB |
testcase_05 | AC | 143 ms
88,568 KB |
testcase_06 | AC | 140 ms
88,584 KB |
testcase_07 | AC | 146 ms
88,596 KB |
testcase_08 | AC | 175 ms
89,340 KB |
testcase_09 | AC | 143 ms
88,404 KB |
testcase_10 | AC | 143 ms
88,428 KB |
testcase_11 | AC | 141 ms
88,604 KB |
testcase_12 | AC | 144 ms
88,860 KB |
testcase_13 | AC | 141 ms
88,508 KB |
testcase_14 | AC | 174 ms
89,272 KB |
testcase_15 | AC | 139 ms
88,444 KB |
testcase_16 | AC | 144 ms
88,732 KB |
testcase_17 | AC | 158 ms
89,632 KB |
testcase_18 | AC | 146 ms
88,612 KB |
testcase_19 | AC | 147 ms
88,688 KB |
testcase_20 | AC | 145 ms
88,684 KB |
testcase_21 | AC | 142 ms
88,644 KB |
testcase_22 | AC | 147 ms
88,808 KB |
testcase_23 | AC | 151 ms
89,140 KB |
testcase_24 | AC | 157 ms
89,340 KB |
testcase_25 | AC | 938 ms
139,976 KB |
testcase_26 | AC | 200 ms
90,456 KB |
testcase_27 | AC | 345 ms
100,528 KB |
testcase_28 | AC | 641 ms
113,772 KB |
testcase_29 | AC | 359 ms
100,824 KB |
testcase_30 | AC | 1,956 ms
193,208 KB |
testcase_31 | TLE | - |
testcase_32 | AC | 211 ms
91,180 KB |
testcase_33 | AC | 1,999 ms
193,444 KB |
testcase_34 | AC | 1,975 ms
193,620 KB |
testcase_35 | AC | 216 ms
91,408 KB |
testcase_36 | AC | 189 ms
90,360 KB |
testcase_37 | AC | 186 ms
90,296 KB |
testcase_38 | AC | 210 ms
91,268 KB |
testcase_39 | AC | 192 ms
90,136 KB |
testcase_40 | AC | 980 ms
139,856 KB |
testcase_41 | AC | 1,975 ms
193,408 KB |
testcase_42 | AC | 1,991 ms
193,280 KB |
testcase_43 | AC | 351 ms
100,584 KB |
testcase_44 | AC | 1,901 ms
193,192 KB |
testcase_45 | AC | 1,882 ms
193,640 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): 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()