結果

問題 No.2718 Best Consonance
ユーザー shinchanshinchan
提出日時 2024-04-06 02:27:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 210,860 KB
実行使用メモリ 11,308 KB
最終ジャッジ日時 2024-04-06 03:25:28
合計ジャッジ時間 7,508 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,064 KB
testcase_01 AC 6 ms
8,064 KB
testcase_02 AC 5 ms
8,064 KB
testcase_03 AC 7 ms
8,064 KB
testcase_04 AC 7 ms
8,064 KB
testcase_05 AC 7 ms
8,064 KB
testcase_06 AC 6 ms
8,064 KB
testcase_07 AC 6 ms
8,064 KB
testcase_08 AC 20 ms
8,064 KB
testcase_09 AC 13 ms
8,064 KB
testcase_10 AC 14 ms
8,064 KB
testcase_11 AC 13 ms
8,064 KB
testcase_12 AC 14 ms
8,064 KB
testcase_13 AC 14 ms
8,064 KB
testcase_14 AC 174 ms
10,084 KB
testcase_15 AC 136 ms
9,828 KB
testcase_16 AC 144 ms
9,828 KB
testcase_17 AC 116 ms
9,572 KB
testcase_18 AC 155 ms
9,956 KB
testcase_19 AC 134 ms
9,700 KB
testcase_20 AC 176 ms
10,084 KB
testcase_21 AC 165 ms
9,956 KB
testcase_22 AC 166 ms
10,084 KB
testcase_23 AC 103 ms
9,444 KB
testcase_24 AC 193 ms
11,308 KB
testcase_25 AC 193 ms
11,308 KB
testcase_26 AC 197 ms
11,308 KB
testcase_27 AC 199 ms
11,308 KB
testcase_28 AC 197 ms
11,308 KB
testcase_29 AC 196 ms
11,308 KB
testcase_30 AC 197 ms
11,308 KB
testcase_31 AC 197 ms
11,308 KB
testcase_32 AC 193 ms
11,308 KB
testcase_33 AC 197 ms
11,308 KB
testcase_34 AC 6 ms
8,064 KB
testcase_35 AC 6 ms
8,064 KB
testcase_36 AC 148 ms
8,064 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
using ll = long long;

int main() {
    ll n, N = 200001, M = 400001, ans = 0; cin >> n;
    vector<ll> B(N, 0);
    for(int i = 0; i < n; i ++) {
        ll a, b;
        cin >> a >> b;
        if(b <= B[a]) ans = max(ans, b);
        else ans = max(ans, B[a]), B[a] = b;
    }
    vector<pair<ll, ll>> v;
    for(ll i = 1; i < N; i ++) if(B[i]) v.push_back({i * B[i], i});
    sort(all(v), [&](pair<ll, ll> a, pair<ll, ll> b){return a > b;});
    vector<ll> exist(M, 0);
    for(auto [ab, a] : v) {
        for(ll i = a; i < M; i += a) {
            if(exist[i]) {
                ans = max(ans, ab / i);
                break;
            }
        }
        for(ll i = a; i < M; i += a) exist[i] = 1;
    }
    cout << ans << endl;
    return 0; 
}
0