結果

問題 No.3085 Easy Problems
コンテスト
ユーザー Musaddiq K
提出日時 2025-12-25 20:03:37
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 545 ms / 2,000 ms
コード長 1,562 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,517 ms
コンパイル使用メモリ 296,116 KB
実行使用メモリ 18,972 KB
最終ジャッジ日時 2025-12-25 20:03:59
合計ジャッジ時間 21,111 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

// #ifndef ONLINE_JUDGE
//     #include "debug/debug_template.cpp"
// #else
//     #define debug(...)
//     #define debugArr(...)
// #endif

#define ll long long
#define nl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define int long long
#define pii pair<int,int>
#define double long double
#define pb push_back
#define here cout<<"HERE"<<nl;
#define forn(i,a,n) for(int i = a; i < n; i++)
#define print(a) for(auto& e : a) cout << e << " "; cout << nl;
#define all(a) a.begin(),a.end()
#define MOD(a,b) ((a%b)+b)%b
#define yesno(b) cout << ((b)? "YES\n" : "NO\n")
template<typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
using namespace std;
void solve() {
    int n;
    cin >> n;
    vector<pii> probs(n);
    forn(i, 0 , n){
        int a, b;
        cin >> a >> b;
        probs[i] = {a, b};
    }

    sort(all(probs));
    vi diffs;
    for(auto [u, v] : probs) diffs.push_back(u);

    map<int, vi> topic;
    for(auto &[u, v] : probs) topic[v].push_back(u);

    for(auto &[u, v] : topic) sort(all(v));

    int q;
    cin >> q;
    while(q--){
        int x, y;
        cin >> x >> y;

        int ez = upper_bound(all(diffs), x) - diffs.begin();

        int bad = 0;
        if(topic.count(y))
            bad = upper_bound(all(topic[y]), x) - topic[y].begin();

        cout << ez - bad << nl;
    }
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--){
        solve();
    }
    return 0;
}
0