結果

問題 No.3085 Easy Problems
ユーザー haihamabossu
提出日時 2025-04-04 21:33:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 2,660 ms
コンパイル使用メモリ 201,332 KB
実行使用メモリ 10,648 KB
最終ジャッジ日時 2025-04-04 21:36:20
合計ジャッジ時間 11,885 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const ll MX = 100010;
void solve() {
  ll n;
  cin >> n;
  vector<ll> as;
  vector<vector<ll>> bas(MX + 10);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    as.push_back(a);
    bas[b].push_back(a);
  }
  sort(as.begin(), as.end());
  rep(i, MX) sort(bas[i].begin(), bas[i].end());
  ll q;
  cin >> q;
  rep(qi, q) {
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    ans += upper_bound(as.begin(), as.end(), x) - as.begin();
    ans -= upper_bound(bas[y].begin(), bas[y].end(), x) - bas[y].begin();
    cout << ans << '\n';
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0