結果

問題 No.3422 Sazanka's hobby
コンテスト
ユーザー LyricalMaestro
提出日時 2026-01-23 01:14:23
言語 PyPy3
(7.3.17)
結果
AC  
実行時間 1,222 ms / 2,000 ms
コード長 838 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 398 ms
コンパイル使用メモリ 82,748 KB
実行使用メモリ 247,940 KB
最終ジャッジ日時 2026-01-23 01:14:35
合計ジャッジ時間 12,174 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/3422

def solve(ab, k, M):
    if k == 0:
        return False

    d = 0
    for i in range(len(ab)):
        x = ab[i]
        d = i // k
        if x <= d:
            return False
    
    return True
        


def main():
    N, M = map(int, input().split())
    ab = []
    for _ in range(N):
        a, b = map(int, input().split())
        ab.append((a, b))

    ab2 = []
    for a, b in ab:
        m = M - a    
        x = m // b
        x += 1
        ab2.append(x)
    ab2.sort()

    low = 0
    high = M
    while high - low > 1:
        mid = (high + low) // 2
        if solve(ab2, mid, M):
            high = mid
        else:
            low = mid
    
    if solve(ab2, low, M):
        print(low)
    else:
        print(high)








    



if __name__ == "__main__":
    main()
0