結果

問題 No.3085 Easy Problems
ユーザー rgnerdplayer
提出日時 2025-05-07 12:15:58
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 434 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 3,637 ms
コンパイル使用メモリ 288,300 KB
実行使用メモリ 15,080 KB
最終ジャッジ日時 2025-05-07 12:16:16
合計ジャッジ時間 16,093 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    auto solve = [&]() {
        int n;
        cin >> n;

        map<int, vector<int>> mp;

        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            mp[0].push_back(a);
            mp[b].push_back(a);
        }

        for (auto &[x, v] : mp) {
            sort(v.begin(), v.end());
        }

        int q;
        cin >> q;

        for (int i = 0; i < q; i++) {
            int x, y;
            cin >> x >> y;

            int ans = upper_bound(mp[0].begin(), mp[0].end(), x) - mp[0].begin();
            ans -= upper_bound(mp[y].begin(), mp[y].end(), x) - mp[y].begin();

            cout << ans << '\n';
        }
    };
    
    solve();
    
    return 0;
}
0