結果
| 問題 | No.3085 Easy  Problems | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-04-04 22:21:57 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 224 ms / 2,000 ms | 
| コード長 | 663 bytes | 
| コンパイル時間 | 2,534 ms | 
| コンパイル使用メモリ | 201,868 KB | 
| 実行使用メモリ | 9,344 KB | 
| 最終ジャッジ日時 | 2025-04-04 22:22:13 | 
| 合計ジャッジ時間 | 11,080 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 31 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> tb(100001);
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        a[i] = x;
        tb[y].emplace_back(x);
    }
    sort(a.begin(), a.end());
    for(auto &&vec : tb) sort(vec.begin(), vec.end());
    int Q;
    cin >> Q;
    while(Q--){
        int x, y;
        cin >> x >> y;
        int ans = upper_bound(a.begin(), a.end(), x) - a.begin();
        ans -= upper_bound(tb[y].begin(), tb[y].end(), x) - tb[y].begin();
        cout << ans << '\n';
    }
}
            
            
            
        