結果
問題 | No.2718 Best Consonance |
ユーザー | flygon |
提出日時 | 2024-04-06 14:45:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,530 ms / 4,000 ms |
コード長 | 1,785 bytes |
コンパイル時間 | 698 ms |
コンパイル使用メモリ | 82,588 KB |
実行使用メモリ | 116,992 KB |
最終ジャッジ日時 | 2024-10-02 13:01:11 |
合計ジャッジ時間 | 28,472 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
66,688 KB |
testcase_01 | AC | 60 ms
66,944 KB |
testcase_02 | AC | 63 ms
66,944 KB |
testcase_03 | AC | 61 ms
66,688 KB |
testcase_04 | AC | 60 ms
67,072 KB |
testcase_05 | AC | 60 ms
66,688 KB |
testcase_06 | AC | 59 ms
66,688 KB |
testcase_07 | AC | 58 ms
66,816 KB |
testcase_08 | AC | 62 ms
66,560 KB |
testcase_09 | AC | 115 ms
80,896 KB |
testcase_10 | AC | 116 ms
81,352 KB |
testcase_11 | AC | 118 ms
81,024 KB |
testcase_12 | AC | 113 ms
80,256 KB |
testcase_13 | AC | 114 ms
81,324 KB |
testcase_14 | AC | 1,166 ms
115,072 KB |
testcase_15 | AC | 907 ms
103,552 KB |
testcase_16 | AC | 967 ms
107,136 KB |
testcase_17 | AC | 787 ms
100,608 KB |
testcase_18 | AC | 1,087 ms
109,440 KB |
testcase_19 | AC | 892 ms
103,800 KB |
testcase_20 | AC | 1,211 ms
115,432 KB |
testcase_21 | AC | 1,127 ms
110,976 KB |
testcase_22 | AC | 1,134 ms
111,728 KB |
testcase_23 | AC | 702 ms
98,304 KB |
testcase_24 | AC | 1,218 ms
116,224 KB |
testcase_25 | AC | 1,267 ms
116,736 KB |
testcase_26 | AC | 1,230 ms
116,992 KB |
testcase_27 | AC | 1,241 ms
116,608 KB |
testcase_28 | AC | 1,220 ms
116,608 KB |
testcase_29 | AC | 1,235 ms
116,736 KB |
testcase_30 | AC | 1,298 ms
116,420 KB |
testcase_31 | AC | 1,247 ms
116,680 KB |
testcase_32 | AC | 1,218 ms
116,356 KB |
testcase_33 | AC | 1,222 ms
116,608 KB |
testcase_34 | AC | 61 ms
66,688 KB |
testcase_35 | AC | 62 ms
67,200 KB |
testcase_36 | AC | 719 ms
114,688 KB |
testcase_37 | AC | 59 ms
67,200 KB |
testcase_38 | AC | 1,530 ms
114,816 KB |
testcase_39 | AC | 61 ms
66,688 KB |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd class Era: def __init__(self, n): self.N = n self.l = [i for i in range(n+1)] for i in range(2,min(n,n//2+10)): if self.l[i] == i: for p in range(i+i,n+1,i): if self.l[p] == p: self.l[p] = i # 素数判定 def isprime(self,n): return self.l[n] == n # 素因数分解 def primes(self,n): ans = [] now = n while now != 1: if not ans: ans.append([self.l[now], 1]) else: if ans[-1][0] == self.l[now]: ans[-1][1] += 1 else: ans.append([self.l[now], 1]) now //= self.l[now] return ans # 約数列挙 def facts(self,n): pf = self.primes(n) ans = [1] for pn, cnt in pf: tmp = [pow(pn, i) for i in range(1, cnt+1)] m = len(ans) for num in tmp: for i in range(m): ans.append(ans[i]*num) return ans era = Era(202020) n = int(input()) ab = [] cs = [] for i in range(n): a,b= map(int,input().split()) c = a*b cs.append((c,i)) ab.append([a,b]) cs.sort() cs = cs[::-1] d = [10**10]*(202020) ans = 0 for ci, i in cs: ai,bi = ab[i] fs = era.facts(ai) tmp = 0 for num in fs: if d[num] == 10**10: continue tmp = max(tmp, bi*num//d[num]) for num in fs: d[num] = min(d[num], ai) ans = max(tmp, ans) print(ans)