結果

問題 No.2718 Best Consonance
ユーザー GOTKAKOGOTKAKO
提出日時 2024-04-05 22:37:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,119 ms / 4,000 ms
コード長 1,360 bytes
コンパイル時間 2,746 ms
コンパイル使用メモリ 215,512 KB
実行使用メモリ 72,544 KB
最終ジャッジ日時 2024-04-10 10:53:08
合計ジャッジ時間 40,451 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 698 ms
12,648 KB
testcase_01 AC 698 ms
12,484 KB
testcase_02 AC 696 ms
12,596 KB
testcase_03 AC 698 ms
12,688 KB
testcase_04 AC 695 ms
12,416 KB
testcase_05 AC 697 ms
12,592 KB
testcase_06 AC 698 ms
12,656 KB
testcase_07 AC 697 ms
12,560 KB
testcase_08 AC 696 ms
12,612 KB
testcase_09 AC 697 ms
12,800 KB
testcase_10 AC 698 ms
12,876 KB
testcase_11 AC 699 ms
12,852 KB
testcase_12 AC 698 ms
13,052 KB
testcase_13 AC 698 ms
12,948 KB
testcase_14 AC 1,066 ms
61,476 KB
testcase_15 AC 993 ms
52,172 KB
testcase_16 AC 1,006 ms
54,348 KB
testcase_17 AC 949 ms
46,244 KB
testcase_18 AC 1,033 ms
56,704 KB
testcase_19 AC 976 ms
52,812 KB
testcase_20 AC 1,068 ms
61,776 KB
testcase_21 AC 1,052 ms
59,364 KB
testcase_22 AC 1,051 ms
59,440 KB
testcase_23 AC 924 ms
43,156 KB
testcase_24 AC 1,102 ms
71,636 KB
testcase_25 AC 1,100 ms
71,636 KB
testcase_26 AC 1,104 ms
71,688 KB
testcase_27 AC 1,110 ms
71,704 KB
testcase_28 AC 1,107 ms
71,712 KB
testcase_29 AC 1,119 ms
72,544 KB
testcase_30 AC 1,113 ms
72,004 KB
testcase_31 AC 1,105 ms
71,744 KB
testcase_32 AC 1,106 ms
71,840 KB
testcase_33 AC 1,109 ms
71,808 KB
testcase_34 AC 696 ms
12,548 KB
testcase_35 AC 696 ms
12,732 KB
testcase_36 AC 748 ms
14,344 KB
testcase_37 AC 697 ms
12,548 KB
testcase_38 AC 750 ms
14,128 KB
testcase_39 AC 698 ms
12,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin >> N;
    vector<vector<long long>> AB(200001);
    for(int i=0; i<N; i++){
        int a,b; cin >> a >> b;
        AB.at(a).push_back(b);
    }

    vector<vector<pair<long long,long long>>> D(200001);
    for(int i=1; i<=200000; i++){
        long long a = i;
        sort(AB.at(i).rbegin(),AB.at(i).rend());
        vector<int> d;
        for(int k=1; k*k<=a; k++){
            if(a%k) continue;
            d.push_back(k);
            if(k*k != a) d.push_back(a/k);
        }
        for(int l=0; l<min((int)AB.at(i).size(),2); l++){
            long long b = AB.at(i).at(l);
            for(auto dd : d) D.at(dd).push_back({a*b,a});
        }
    }

    long long answer = 0;
    for(int i=1; i<=200000; i++){
        int n = D.at(i).size();
        vector<long long> mina(n);
        sort(D.at(i).begin(),D.at(i).end());
        for(int k=n-1; k>=0; k--){
            if(k != n-1) mina.at(k) = min(D.at(i).at(k).second,mina.at(k+1));
            else mina.at(k) = D.at(i).at(k).second;
        }

        for(int k=0; k<n-1; k++){
            auto[limit,a1] = D.at(i).at(k);
            auto[ign,a2] = D.at(i).at(k+1);
            answer = max(answer,limit/(a1*a2/i));
        }
    }
    cout << answer << endl;
}
0