結果

問題 No.2718 Best Consonance
ユーザー ecotteaecottea
提出日時 2024-02-03 19:08:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,529 ms / 4,000 ms
コード長 840 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 147,700 KB
最終ジャッジ日時 2024-04-10 10:50:09
合計ジャッジ時間 41,953 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,388 KB
testcase_01 AC 33 ms
52,420 KB
testcase_02 AC 33 ms
52,400 KB
testcase_03 AC 33 ms
53,624 KB
testcase_04 AC 35 ms
52,564 KB
testcase_05 AC 34 ms
52,856 KB
testcase_06 AC 33 ms
52,144 KB
testcase_07 AC 35 ms
52,616 KB
testcase_08 AC 35 ms
52,760 KB
testcase_09 AC 80 ms
76,700 KB
testcase_10 AC 84 ms
76,960 KB
testcase_11 AC 80 ms
76,900 KB
testcase_12 AC 80 ms
76,424 KB
testcase_13 AC 81 ms
77,040 KB
testcase_14 AC 1,522 ms
117,012 KB
testcase_15 AC 1,260 ms
108,912 KB
testcase_16 AC 1,338 ms
109,600 KB
testcase_17 AC 1,091 ms
105,124 KB
testcase_18 AC 1,471 ms
112,812 KB
testcase_19 AC 1,213 ms
106,328 KB
testcase_20 AC 1,550 ms
117,352 KB
testcase_21 AC 1,449 ms
114,456 KB
testcase_22 AC 1,463 ms
114,848 KB
testcase_23 AC 992 ms
99,388 KB
testcase_24 AC 2,519 ms
147,572 KB
testcase_25 AC 2,493 ms
147,320 KB
testcase_26 AC 2,500 ms
147,448 KB
testcase_27 AC 2,472 ms
147,448 KB
testcase_28 AC 2,529 ms
147,316 KB
testcase_29 AC 2,512 ms
147,640 KB
testcase_30 AC 2,482 ms
147,576 KB
testcase_31 AC 2,495 ms
147,316 KB
testcase_32 AC 2,478 ms
147,440 KB
testcase_33 AC 2,476 ms
147,700 KB
testcase_34 AC 38 ms
58,836 KB
testcase_35 AC 60 ms
75,952 KB
testcase_36 AC 164 ms
81,328 KB
testcase_37 AC 55 ms
75,540 KB
testcase_38 AC 162 ms
81,144 KB
testcase_39 AC 33 ms
52,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

a_max = max(a)

res = 0

a_to_bmax = [-1] * (a_max + 1)
for i in range(n):
    if a_to_bmax[a[i]] == -1:
        a_to_bmax[a[i]] = b[i]
    else:
        res = max(res, min(a_to_bmax[a[i]], b[i]))
        a_to_bmax[a[i]] = max(a_to_bmax[a[i]], b[i])

for g in range(1, a_max // 2 + 1):
    ab_a_b = []
    for a in range(g, a_max + 1, g):
        b = a_to_bmax[a]
        if b == -1:
            continue
        ab_a_b.append([a * b, a, b])
    ab_a_b.sort()
    K = len(ab_a_b)

    a_min = [a_max + 1] * (K + 1)
    for k in range(K - 1, -1, -1):
        ab, a, b = ab_a_b[k]
        a_min[k] = min(a_min[k + 1], a)

    for k in range(K - 1):
        ab, a, b = ab_a_b[k]
        res = max(res, (b * g) // a_min[k + 1])

print(res)
0