結果
問題 |
No.3085 Easy Problems
|
ユーザー |
![]() |
提出日時 | 2025-04-04 22:15:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 418 ms / 2,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 2,074 ms |
コンパイル使用メモリ | 208,556 KB |
実行使用メモリ | 16,996 KB |
最終ジャッジ日時 | 2025-04-04 22:16:13 |
合計ジャッジ時間 | 16,460 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using VI = vector<int>; using P = pair<int, int>; constexpr int INF = 1001001001; constexpr ll LINF = 1001001001001001001ll; #define rep(i, n) for (ll i = 0; i < (int)(n); i++) int main(){ int n; cin >> n; vector<P> v(n); // vector<int> v(n); rep(i, n){ cin >> v[i].first >> v[i].second; } sort(v.begin(), v.end()); // VI v2(n); // rep(i, n){ // v2[i] = v[i].first; // } int q; cin >> q; VI ans(q); vector<vector<int>> xy(q, VI(3)); rep(i, q){ int x, y; cin >> x >> y; xy[i][0] = x; xy[i][1] = y; xy[i][2] = i; } sort(xy.begin(), xy.end()); vector<int> cntB(1e5+1, 0); int idx = -1; rep(i, q){ while(idx+1 <= n-1 && v[idx+1].first <= xy[i][0]){ idx++; int b = v[idx].second; cntB[b]++; // cout << 'b' << v[idx+1].first << ' ' << xy[i][0] << endl; } int y = xy[i][1], qi = xy[i][2]; ans[qi] = idx+1 - cntB[y]; // cout << idx+1 << ' ' << cntB[y]<< endl; } rep(i, q){ cout << ans[i] << "\n"; } }