結果

問題 No.817 Coin donation
コンテスト
ユーザー AEn
提出日時 2022-05-23 15:51:16
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 293 ms / 2,000 ms
+ 841µs
コード長 492 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 110 ms
コンパイル使用メモリ 64,452 KB
実行使用メモリ 97,236 KB
最終ジャッジ日時 2026-11-06 01:43:55
合計ジャッジ時間 3,627 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, K = map(int, input().split())
m = []
for i in range(N):
    A, B = map(int, input().split())
    m.append([1, A])
    m.append([-1, B+1])
m.sort(key = lambda x:x[1])
id, cnt, all_num = 0, 0, 0
s = m[0][1]
while True:
    w, n = m[id]
    if s == n:
        cnt += w
        id += 1
    else:
        if all_num + cnt * (n-s) < K:
            all_num += cnt*(n-s)
            s = n
        else:
            c, d = divmod((K-all_num), cnt)
            print(s+(c-1)+(d>0))
            break
0