結果
問題 |
No.817 Coin donation
|
ユーザー |
![]() |
提出日時 | 2021-01-18 03:30:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 576 ms / 2,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 64,620 KB |
最終ジャッジ日時 | 2024-11-30 11:25:03 |
合計ジャッジ時間 | 3,478 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
from sys import stdin from itertools import accumulate readline = stdin.readline N, K = map(int, readline().split()) AB = [tuple(map(int, readline().split())) for _ in range(N)] p = set() for a, b in AB: p.add(a) p.add(b + 1) inv = sorted(p) fwd = {} for i in range(len(inv)): fwd[inv[i]] = i t = [0] * len(inv) for a, b in AB: t[fwd[a]] += 1 t[fwd[b + 1]] -= 1 t = list(accumulate(t)) c = 0 for i in range(len(t)): x = c + t[i] * (inv[i + 1] - inv[i]) if x < K: c = x continue print(inv[i] + (K - c - 1) // t[i]) break