結果
問題 | No.2718 Best Consonance |
ユーザー | flygon |
提出日時 | 2024-04-06 14:41:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,137 ms / 4,000 ms |
コード長 | 1,795 bytes |
コンパイル時間 | 440 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 150,536 KB |
最終ジャッジ日時 | 2024-10-02 13:00:15 |
合計ジャッジ時間 | 33,137 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
67,192 KB |
testcase_01 | AC | 57 ms
65,356 KB |
testcase_02 | AC | 58 ms
66,392 KB |
testcase_03 | AC | 56 ms
66,104 KB |
testcase_04 | AC | 55 ms
65,908 KB |
testcase_05 | AC | 56 ms
66,244 KB |
testcase_06 | AC | 56 ms
66,104 KB |
testcase_07 | AC | 57 ms
67,120 KB |
testcase_08 | AC | 57 ms
67,324 KB |
testcase_09 | AC | 112 ms
79,772 KB |
testcase_10 | AC | 114 ms
79,664 KB |
testcase_11 | AC | 114 ms
79,612 KB |
testcase_12 | AC | 109 ms
79,228 KB |
testcase_13 | AC | 114 ms
79,620 KB |
testcase_14 | AC | 1,314 ms
139,516 KB |
testcase_15 | AC | 1,062 ms
124,292 KB |
testcase_16 | AC | 1,099 ms
128,256 KB |
testcase_17 | AC | 928 ms
120,712 KB |
testcase_18 | AC | 1,235 ms
133,304 KB |
testcase_19 | AC | 1,033 ms
123,860 KB |
testcase_20 | AC | 1,409 ms
139,440 KB |
testcase_21 | AC | 1,282 ms
134,208 KB |
testcase_22 | AC | 1,327 ms
135,624 KB |
testcase_23 | AC | 791 ms
115,952 KB |
testcase_24 | AC | 1,419 ms
149,848 KB |
testcase_25 | AC | 1,471 ms
149,592 KB |
testcase_26 | AC | 1,536 ms
150,496 KB |
testcase_27 | AC | 1,473 ms
149,760 KB |
testcase_28 | AC | 1,526 ms
150,144 KB |
testcase_29 | AC | 1,517 ms
149,888 KB |
testcase_30 | AC | 1,483 ms
150,104 KB |
testcase_31 | AC | 1,507 ms
149,068 KB |
testcase_32 | AC | 1,458 ms
150,004 KB |
testcase_33 | AC | 1,488 ms
150,536 KB |
testcase_34 | AC | 55 ms
66,336 KB |
testcase_35 | AC | 55 ms
65,676 KB |
testcase_36 | AC | 866 ms
113,516 KB |
testcase_37 | AC | 56 ms
66,464 KB |
testcase_38 | AC | 2,137 ms
113,668 KB |
testcase_39 | AC | 55 ms
66,104 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 = defaultdict(lambda :10**10) 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)