結果
| 問題 |
No.2718 Best Consonance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-10 09:30:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,816 ms / 4,000 ms |
| コード長 | 1,344 bytes |
| コンパイル時間 | 587 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 158,448 KB |
| 最終ジャッジ日時 | 2025-06-10 09:31:22 |
| 合計ジャッジ時間 | 36,409 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 |
ソースコード
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, 0] for _ in range(M + 1)]
for _ in range(N):
a, b = map(int, input[ptr:ptr + 2]); ptr += 2
if MA[a][0] < b:
MA[a] = [b, MA[a][0]]
elif MA[a][1] < b:
MA[a][1] = b
ans = max(row[1] for row in MA)
for g in range(1, M + 1):
L = []
for a in range(g, M + 1, g):
b = MA[a][0]
if b > 0:
L.append((a // g, b))
if len(L) < 2:
continue
L.sort(key=lambda x: x[0] * x[1], reverse=True)
alt = 0
aa = inf
for a, b in L:
if alt < b // aa:
alt = b // aa
if aa > a:
aa = a
if ans < alt:
ans = alt
print(ans)
if __name__ == "__main__":
main()