結果

問題 No.2718 Best Consonance
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-06 12:59:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 4,000 ms
コード長 1,023 bytes
コンパイル時間 2,618 ms
コンパイル使用メモリ 203,628 KB
実行使用メモリ 9,852 KB
最終ジャッジ日時 2024-04-10 10:56:49
合計ジャッジ時間 8,518 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,816 KB
testcase_01 AC 5 ms
6,940 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 6 ms
6,944 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 6 ms
6,948 KB
testcase_10 AC 6 ms
6,944 KB
testcase_11 AC 6 ms
6,944 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 6 ms
6,940 KB
testcase_14 AC 173 ms
6,944 KB
testcase_15 AC 142 ms
6,940 KB
testcase_16 AC 152 ms
6,940 KB
testcase_17 AC 128 ms
6,944 KB
testcase_18 AC 160 ms
6,940 KB
testcase_19 AC 140 ms
6,940 KB
testcase_20 AC 173 ms
6,944 KB
testcase_21 AC 166 ms
6,940 KB
testcase_22 AC 171 ms
6,944 KB
testcase_23 AC 117 ms
6,948 KB
testcase_24 AC 243 ms
9,468 KB
testcase_25 AC 245 ms
8,564 KB
testcase_26 AC 244 ms
9,464 KB
testcase_27 AC 249 ms
8,564 KB
testcase_28 AC 244 ms
9,852 KB
testcase_29 AC 243 ms
8,188 KB
testcase_30 AC 246 ms
8,572 KB
testcase_31 AC 244 ms
8,828 KB
testcase_32 AC 244 ms
8,440 KB
testcase_33 AC 269 ms
8,568 KB
testcase_34 AC 5 ms
6,944 KB
testcase_35 AC 5 ms
6,944 KB
testcase_36 AC 51 ms
6,944 KB
testcase_37 AC 5 ms
6,944 KB
testcase_38 AC 52 ms
6,944 KB
testcase_39 AC 5 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n;
    cin >> n;
    const int M = 2e5;
    vector<int> b(M + 1);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a, bb;
        cin >> a >> bb;
        ans = max(ans, (long long)min(bb, b[a]));
        b[a] = max(b[a], bb);
    }
    using pll = pair<long long, long long>;

    for (int g = 1; g <= M; g++) {
        vector<pll> ab;
        for (int i = g; i <= M; i += g) {
            if (b[i] > 0) {
                ab.push_back({i, b[i]});
            }
        }
        if (ab.size() < 2) {
            continue;
        }
        sort(ab.begin(), ab.end(), [&](pll a, pll b) {
            return a.first * a.second < b.first * b.second;
        });
        long long b_ma = 0;
        for (auto [a, b] : ab) {
            ans = max(ans, b_ma / (a / g));
            b_ma = max(b_ma, b);
        }
    }
    cout << ans << endl;
}
0