結果

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

ソースコード

diff #
raw source code

import sys, math
sys.setrecursionlimit(10**8)
sys.set_int_max_str_digits(0)
INF = 1e18
MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush
def I():   return sys.stdin.readline().rstrip()
def II():  return int(sys.stdin.readline().rstrip())
def IS():  return sys.stdin.readline().rstrip().split()
def MII(): return map(int, sys.stdin.readline().rstrip().split())
def LI():  return list(sys.stdin.readline().rstrip())
def TII(): return tuple(map(int, sys.stdin.readline().rstrip().split()))
def LII(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LSI(): return list(map(str, sys.stdin.readline().rstrip().split()))
def GMI(): return list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
def kiriage(a, b): return (a+b-1)//b
def chmax(DP,i,v):
    if DP[i] < v: DP[i] = v
def chmin(DP,i,v):
    if DP[i] > v: DP[i] = v

N, M = MII()
cnt = defaultdict(int)
for i in range(N):
    a, b = MII()
    sho, amari = divmod(M + 1 - a, b)
    if amari == 0:
        x = sho
    else:
        x = sho + 1    
    cnt[x] += 1

def solve(k):
    SUM = 0
    for day in sorted(cnt.keys()):
        SUM += cnt[day]
        # 取り除く能力
        # k * day
        # この日までに取り除かないといけない個数累積
        # SUM
        if k*day < SUM:
            return False    
    return True

ok = N
ng = 0
while abs(ok - ng) != 1:
    mid = (ok + ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0