結果

問題 No.2543 Many Meetings
ユーザー ShirotsumeShirotsume
提出日時 2023-11-14 13:30:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,080 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 116,980 KB
最終ジャッジ日時 2023-11-14 13:31:09
合計ジャッジ時間 11,425 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 40 ms
56,272 KB
testcase_02 AC 38 ms
56,272 KB
testcase_03 AC 388 ms
107,532 KB
testcase_04 AC 418 ms
108,172 KB
testcase_05 AC 398 ms
107,532 KB
testcase_06 AC 396 ms
107,660 KB
testcase_07 AC 449 ms
107,916 KB
testcase_08 WA -
testcase_09 AC 395 ms
107,660 KB
testcase_10 AC 433 ms
107,532 KB
testcase_11 AC 392 ms
107,532 KB
testcase_12 AC 420 ms
107,660 KB
testcase_13 AC 331 ms
95,148 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 41 ms
56,272 KB
testcase_25 WA -
testcase_26 AC 44 ms
58,332 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 108 ms
80,180 KB
testcase_32 AC 232 ms
92,192 KB
testcase_33 AC 41 ms
56,272 KB
testcase_34 AC 42 ms
56,272 KB
testcase_35 AC 41 ms
56,272 KB
testcase_36 AC 40 ms
56,272 KB
testcase_37 AC 40 ms
56,272 KB
testcase_38 AC 40 ms
56,272 KB
testcase_39 WA -
testcase_40 AC 41 ms
56,272 KB
testcase_41 AC 41 ms
56,272 KB
testcase_42 AC 41 ms
56,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#嘘解法
def solve(n, k, LR):
    LR.sort(key = lambda x: x[1])
    inf = 2 ** 63 - 1
    ans = inf
    D = []
    now = -1
    for l, r in LR:
        if l > now:
            now = r
            D.append((l, r))
    for i in range(len(D)):
        if i + k - 1 < len(D):
            ans = min(ans, D[i + k - 1][1] - D[i][0])
    return ans if ans < inf else -1
        

def solve_gu(n, k, LR):
    import itertools
    ans = inf
    for v in itertools.combinations(LR, k):
        v = list(v)
        v.sort(key = lambda x: x[1])
        
        now = -1
        f = True
        for l, r in v:
            if l < now:
                f = False
            now = r
        if f:
            ans = min(ans, v[-1][-1] - v[0][0])
    return ans if ans < inf else -1
import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n, k = mi()
LR = [li() for _ in range(n)]

print(solve(n, k, LR))
0