結果

問題 No.2718 Best Consonance
ユーザー dp_ijk
提出日時 2024-06-22 13:41:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,096 ms / 4,000 ms
コード長 599 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 134,376 KB
最終ジャッジ日時 2024-06-22 13:41:56
合計ジャッジ時間 39,584 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def divisors(X):
   assert X >= 1
   from math import isqrt
   head = [d for d in range(1, isqrt(X) + 1) if X%d == 0]
   tail = [X//d for d in reversed(head)]
   if isqrt(X)**2 == X:
      head.pop()
   return head + tail

INF = 10**18
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda ab: ab[0] * ab[1], reverse=True)
d = defaultdict(lambda: INF)

ans = 0
for a, b in AB:
   for g in divisors(a):
      na = d[g]
      score = b*g//na
      if ans < score:
         ans = score
      d[g] = min(d[g], a)

print(ans)
0