結果

問題 No.2718 Best Consonance
ユーザー shinchan
提出日時 2024-04-06 02:38:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 853 bytes
コンパイル時間 2,536 ms
コンパイル使用メモリ 204,028 KB
最終ジャッジ日時 2025-02-20 22:21:03
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
const ll N = 200001, M = 400001;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, ans = 0;
    cin >> n;
    vector<ll> B(N, 0);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ans = max(ans, min(b, B[a]));
        B[a] = max(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));
    reverse(all(v));

    vector<ll> exist(M, 0);
    for(auto [Max, x] : v) {
        for(ll i = x; i < M; i += x) if(exist[i]) {
            ans = max(ans, Max / i);
            break;
        }
        for(ll i = x; i < M; i += x) exist[i] = 1;
    }
    cout << ans << endl;
    return 0; 
}
0