結果

問題 No.3085 Easy Problems
コンテスト
ユーザー vjudge1
提出日時 2026-01-03 18:03:24
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 1,033 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,202 ms
コンパイル使用メモリ 227,120 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2026-01-03 18:03:50
合計ジャッジ時間 11,991 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//
// e.cpp
// Created by wasifshahzad on 01/03/26 at 12:52:54.
//

#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

const int MOD1 = 1e9+7;
const int MOD2 = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    vector<vector<int>> loc(1e5 + 1);
    for(int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++) {
        loc[a[i].second].push_back(i);
    }
    int q;
    cin >> q;
    while(q--) {
        int x, y;
        cin >> x >> y;
        int j = upper_bound(a.begin(), a.end(), pair<int, int>{x, 1e6}) - a.begin();
        int k = lower_bound(loc[y].begin(), loc[y].end(), j) - loc[y].begin();
        int ans = j - k;
        cout << ans << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
}
0