結果

問題 No.2718 Best Consonance
ユーザー しもりん
提出日時 2025-06-10 09:01:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,305 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 139,056 KB
最終ジャッジ日時 2025-06-10 09:02:34
合計ジャッジ時間 29,122 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush, nlargest, nsmallest
from bisect import bisect_left, bisect, bisect_right
from copy import deepcopy
from time import perf_counter
import sys
from typing import Any, List, Callable


def debug(*args, sep=" ", end="\n") -> None:
    print(*args, sep=sep, end=end, file=sys.stderr)


def main():
    global inf, MOD
    input = sys.stdin.read().split()
    ptr = 0
    inf = float("inf")
    MOD = 998244353

    N = int(input[ptr]); ptr += 1
    M = 200000
    MA = [0] * (M + 1)
    mA = [inf] * (M + 1)
    flg = [False] * (M + 1)
    for _ in range(N):
        a, b = map(int, input[ptr:ptr + 2]); ptr += 2
        MA[a] = max(MA[a], b)
        if mA[a] < inf:
            flg[a] = True
        mA[a] = min(mA[a], b)
    ans = max(b for a, b in enumerate(mA) if flg[a]) if any(flg) else 0
    for g in range(1, M + 1):
        L = []
        for a in range(g, M + 1, g):
            b = MA[a]
            if b > 0:
                L.append((a // g, b))
        if len(L) < 2:
            continue
        L.sort(key=lambda x: x[0] * x[1])
        alt = max(L[i][1] // L[i + 1][0] for i in range(len(L) - 1))
        if ans < alt:
            ans = alt
    print(ans)


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