結果

問題 No.3085 Easy Problems
ユーザー er
提出日時 2025-04-05 20:09:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,038 bytes
コンパイル時間 4,299 ms
コンパイル使用メモリ 288,904 KB
実行使用メモリ 21,120 KB
最終ジャッジ日時 2025-04-05 20:09:55
合計ジャッジ時間 20,439 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define arr(a) a.rbegin(), a.rend()
using ll = long long;

//Konishii

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    vector<vector<int>> cnt(int(1e5 + 1));
    map<ll,ll> m;
    rep(i, n) {
        int a, b; cin >> a >> b;
        cnt[b].push_back(a);
        m[a]++;
    }
    rep(i, int(1e5+1)) {
        if(cnt[i].size()) {
            sort(all(cnt[i]));
        }
    }
    m[0] = 0;
    ll pre = 0;
    for(auto [k, v] : m) {
        m[k] += m[pre];
        pre = k;
    }
    m[int(1e5) + 1] = m[pre];
    int q; cin >> q;
    rep(i, q) {
        int x, y; cin >> x >> y;
        auto it = m.lower_bound(x);
        int mi = upper_bound(all(cnt[y]), x) - cnt[y].begin();
        if(it->first == x) {
            cout << m[x]  - mi << "\n";
        }
        else {
            it--;
            cout << m[it->first] - mi << "\n";
        }
    }
}
0