結果

問題 No.817 Coin donation
ユーザー AEnAEn
提出日時 2022-05-23 15:51:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 97,368 KB
最終ジャッジ日時 2023-10-20 17:30:40
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,380 KB
testcase_01 AC 33 ms
53,380 KB
testcase_02 AC 32 ms
53,380 KB
testcase_03 AC 34 ms
53,380 KB
testcase_04 AC 33 ms
53,380 KB
testcase_05 AC 59 ms
70,716 KB
testcase_06 AC 84 ms
78,040 KB
testcase_07 AC 93 ms
78,564 KB
testcase_08 AC 233 ms
90,416 KB
testcase_09 AC 102 ms
79,040 KB
testcase_10 AC 323 ms
97,368 KB
testcase_11 AC 335 ms
97,356 KB
testcase_12 AC 330 ms
97,356 KB
testcase_13 AC 33 ms
53,380 KB
testcase_14 AC 34 ms
53,380 KB
testcase_15 AC 33 ms
53,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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