結果

問題 No.3640 Babies don't like Bat Beat
コンテスト
ユーザー yuunegi
提出日時 2026-08-25 15:53:32
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 151 ms / 2,000 ms
+ 724µs
コード長 1,087 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,166 ms
コンパイル使用メモリ 342,604 KB
実行使用メモリ 15,840 KB
最終ジャッジ日時 2026-08-25 15:53:43
合計ジャッジ時間 5,871 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サンプル 0 %
小課題1 10 % AC * 5
小課題2 10 % AC * 10
小課題3 15 % AC * 5
小課題4 20 % AC * 10
小課題5 20 % AC * 15
小課題6 25 % AC * 33
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
struct R{
    //>=0&&de!=0
    long long nu,de;
    bool operator<(const R& other) const {
        return (__int128)nu*other.de<(__int128)de*other.nu;
    }
    bool operator==(const R& other) const {
        return (__int128)nu*other.de==(__int128)de*other.nu;
    }
};

int main(void){
    int n;
    cin>>n;
    vector<pair<R,int>>v;
    vector<int>p2;
    for(int i=0;i<31;i++){
        p2.push_back(1<<i);
    }
    int ans=0,sum=0;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        auto iter=upper_bound(p2.begin(), p2.end(),l);
        int pos = iter-p2.begin()-1;
        v.push_back({{l,p2[pos]},1});
        if(p2[pos]*2<=r)sum++;
        iter=upper_bound(p2.begin(), p2.end(),r);
        pos = iter-p2.begin()-1;
        v.push_back({{r,p2[pos]},-1});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        sum+=v[i].second;
        //cout<<sum<<" "<<ans<<" "<<v[i].second<<" "<<v[i].first.nu<<" "<<v[i].first.de<<endl;
        ans=max(sum,ans);
    }
    cout<<ans<<endl;
    return 0;
}
0