結果

問題 No.2718 Best Consonance
ユーザー tassei903tassei903
提出日時 2024-04-05 22:07:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,941 ms / 4,000 ms
コード長 966 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 180,168 KB
最終ジャッジ日時 2024-04-10 10:51:20
合計ジャッジ時間 50,494 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
83,992 KB
testcase_01 AC 107 ms
83,852 KB
testcase_02 AC 103 ms
84,136 KB
testcase_03 AC 102 ms
84,236 KB
testcase_04 AC 101 ms
83,808 KB
testcase_05 AC 101 ms
84,080 KB
testcase_06 AC 101 ms
84,008 KB
testcase_07 AC 104 ms
84,152 KB
testcase_08 AC 102 ms
83,596 KB
testcase_09 AC 162 ms
88,168 KB
testcase_10 AC 153 ms
88,420 KB
testcase_11 AC 149 ms
88,108 KB
testcase_12 AC 147 ms
88,220 KB
testcase_13 AC 152 ms
88,644 KB
testcase_14 AC 1,870 ms
166,988 KB
testcase_15 AC 1,542 ms
145,208 KB
testcase_16 AC 1,647 ms
146,252 KB
testcase_17 AC 1,381 ms
136,692 KB
testcase_18 AC 1,754 ms
162,924 KB
testcase_19 AC 1,515 ms
139,232 KB
testcase_20 AC 1,890 ms
168,064 KB
testcase_21 AC 1,838 ms
155,808 KB
testcase_22 AC 1,844 ms
157,444 KB
testcase_23 AC 1,273 ms
137,148 KB
testcase_24 AC 2,906 ms
179,840 KB
testcase_25 AC 2,941 ms
179,912 KB
testcase_26 AC 2,893 ms
180,168 KB
testcase_27 AC 2,899 ms
179,652 KB
testcase_28 AC 2,906 ms
179,668 KB
testcase_29 AC 2,881 ms
179,784 KB
testcase_30 AC 2,902 ms
179,720 KB
testcase_31 AC 2,900 ms
179,780 KB
testcase_32 AC 2,908 ms
179,920 KB
testcase_33 AC 2,890 ms
179,796 KB
testcase_34 AC 99 ms
84,000 KB
testcase_35 AC 103 ms
84,140 KB
testcase_36 AC 294 ms
131,092 KB
testcase_37 AC 105 ms
83,820 KB
testcase_38 AC 297 ms
131,476 KB
testcase_39 AC 101 ms
83,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n = ni()
m = 2*10**5+2
a,b = zip(*[na() for _ in range(n)])

ans = -1
from math import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

g = [[] for i in range(m)]
for i in range(n):
    g[a[i]].append(b[i])

for i in range(m):
    g[i] = sorted(g[i])
    if len(g[i]) >= 2:
        ans = max(ans, g[i][-2])

for d in range(1, m):
    f = []
    for j in range(d, m, d):
        if len(g[j]):
            f.append((j * g[j][-1], j, g[j][-1]))
    f.sort()
    #print(d, f)
    maxb = -10**18
    for i in range(len(f)):
        ans = max(ans, maxb * d // f[i][1])
        maxb = max(maxb, f[i][2])

print(ans)
0