結果
| 問題 | No.3085 Easy  Problems | 
| コンテスト | |
| ユーザー |  tobbie | 
| 提出日時 | 2025-04-08 12:56:08 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,088 ms / 2,000 ms | 
| コード長 | 648 bytes | 
| コンパイル時間 | 2,602 ms | 
| コンパイル使用メモリ | 205,928 KB | 
| 実行使用メモリ | 15,052 KB | 
| 最終ジャッジ日時 | 2025-04-08 12:56:44 | 
| 合計ジャッジ時間 | 35,443 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 31 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
int main() {
  int n; cin >> n;
  vector<int> a;
  map<int, vector<int>> b;
  rep(i, n) {
    int ai, bi;
    cin >> ai >> bi;
    a.push_back(ai);
    b[bi].push_back(ai);
  }
  sort(a.begin(), a.end());
  for (auto it = b.begin(); it != b.end(); it++)
    sort(it->second.begin(), it->second.end());
  int q; cin >> q;
  rep(i, q) {
    int x, y;
    cin >> x >> y;
    int ans = (upper_bound(a.begin(), a.end(), x) - a.begin()) -
              (upper_bound(b[y].begin(), b[y].end(), x) - b[y].begin());
    cout << ans << endl;
  }
  return 0;
}
            
            
            
        