結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long n;
    cin >> n;
    vector<pair<long long, long long>> items(n);
    for (long long i = 0; i < n; ++i) {
        cin >> items[i].first >> items[i].second;
    }
    sort(items.begin(), items.end());

    vector<vector<long long>> cnt(100030);
    vector<long long> idxs(n);
    for (long long i = 0; i < n; ++i) {
        idxs[i] = items[i].first;
        cnt[items[i].second].push_back(items[i].first);
    }
	for (auto &v : cnt) {
        sort(v.begin(), v.end());
    }
    long long q;
    cin >> q;
    while (q--) {
        long long x, y;
        cin >> x >> y;
        long long total = upper_bound(idxs.begin(), idxs.end(), x) - idxs.begin();
        long long removed = upper_bound(cnt[y].begin(), cnt[y].end(), x) - cnt[y].begin();
        cout << total - removed << "\n";
    }

    return 0;
}
0