結果
| 問題 | No.3085 Easy  Problems | 
| コンテスト | |
| ユーザー |  れいん | 
| 提出日時 | 2025-04-18 18:48:27 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 647 ms / 2,000 ms | 
| コード長 | 974 bytes | 
| コンパイル時間 | 3,382 ms | 
| コンパイル使用メモリ | 285,228 KB | 
| 実行使用メモリ | 10,112 KB | 
| 最終ジャッジ日時 | 2025-04-18 18:48:55 | 
| 合計ジャッジ時間 | 24,908 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 31 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> P(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i].first >> P[i].second;
    }
    vector<vector<int>> T(1e5 + 1);
    sort(P.begin(), P.end());
    for (int i = 0; i < N; i++)
    {
        T[P[i].second].push_back(i);
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int X, Y;
        cin >> X >> Y;
        auto it = upper_bound(P.begin(), P.end(), X, [](int x, const pair<int, int> &p)
                              { return x < p.first; });
        int ans = 0;
        if (it != P.begin())
        {
            it--;
            ans = it - P.begin() + 1;
            auto it2 = upper_bound(T[Y].begin(), T[Y].end(), it - P.begin());
            if (it2 != T[Y].begin())
            {
                it2--;
                ans -= it2 - T[Y].begin() + 1;
            }
        }
        cout << ans << "\n";
    }
}
            
            
            
        