結果

問題 No.2718 Best Consonance
ユーザー shinchanshinchan
提出日時 2024-04-05 22:44:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,114 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 210,936 KB
実行使用メモリ 13,008 KB
最終ジャッジ日時 2024-04-06 03:19:53
合計ジャッジ時間 5,846 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,832 KB
testcase_01 AC 7 ms
8,832 KB
testcase_02 AC 6 ms
8,832 KB
testcase_03 AC 9 ms
8,832 KB
testcase_04 AC 8 ms
8,832 KB
testcase_05 AC 8 ms
8,832 KB
testcase_06 AC 7 ms
8,832 KB
testcase_07 AC 18 ms
8,832 KB
testcase_08 AC 7 ms
8,832 KB
testcase_09 AC 14 ms
8,832 KB
testcase_10 AC 15 ms
8,832 KB
testcase_11 AC 15 ms
8,832 KB
testcase_12 AC 16 ms
8,832 KB
testcase_13 AC 15 ms
8,832 KB
testcase_14 AC 75 ms
10,888 KB
testcase_15 AC 61 ms
10,580 KB
testcase_16 AC 65 ms
10,672 KB
testcase_17 AC 54 ms
10,404 KB
testcase_18 AC 71 ms
10,752 KB
testcase_19 AC 64 ms
10,536 KB
testcase_20 AC 78 ms
10,892 KB
testcase_21 AC 74 ms
10,828 KB
testcase_22 AC 74 ms
10,844 KB
testcase_23 AC 49 ms
10,288 KB
testcase_24 AC 97 ms
13,008 KB
testcase_25 AC 96 ms
13,008 KB
testcase_26 AC 95 ms
13,008 KB
testcase_27 AC 94 ms
13,008 KB
testcase_28 AC 95 ms
13,008 KB
testcase_29 AC 97 ms
13,008 KB
testcase_30 AC 97 ms
13,008 KB
testcase_31 AC 94 ms
13,008 KB
testcase_32 AC 93 ms
13,008 KB
testcase_33 AC 97 ms
13,008 KB
testcase_34 AC 6 ms
8,832 KB
testcase_35 AC 6 ms
8,832 KB
testcase_36 AC 45 ms
8,832 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
#define rep(i, n) for(int i=0;i<n;i++)
#define foa(e, v) for(auto&& e : v)
using ll = long long;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60);
#define dout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll N = 200000;
    vector<ll> B(N + 1, 0);
    ll ans = 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 = N; i >= 1; i --) {
        if(B[i]) v.push_back({i * B[i], i});
    }
    ll M = 500000;
    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