結果

問題 No.3085 Easy Problems
コンテスト
ユーザー Coder123
提出日時 2025-12-29 17:57:30
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 483 ms / 2,000 ms
コード長 2,067 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,021 ms
コンパイル使用メモリ 223,344 KB
実行使用メモリ 10,676 KB
最終ジャッジ日時 2025-12-29 17:57:54
合計ジャッジ時間 22,542 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:36: warning: "INT_MAX" redefined
   36 | #define INT_MAX LLONG_MAX
      | 
In file included from /usr/include/c++/13/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:38,
                 from main.cpp:10:
/usr/lib/gcc/x86_64-linux-gnu/13/include/limits.h:120: note: this is the location of the previous definition
  120 | #define INT_MAX __INT_MAX__
      | 

ソースコード

diff #
raw source code

/*   Bismillah
*    Author: Akhyar Ahmed Turk
*    Created: 2025-12-29 13:43 (GMT+5)

*    brain["Motivation"].insert("Ya to win hy ya learn");

*    Those who can't remember the past are condemned to repeat it.
*                                                 -Dynamic Programming.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// use when u need indexing in sets like (when you need lower upper bound while frequently updating set) 
// idx.order_of_key(value) for nums<value idx.order_of_key(value+1) for nums<=value
// idx.find_by_order(n); to get the nth value by order
#define int long long
#define ld long double
#define yesno(b) cout << ((b) ? "YES" : "NO") << "\n";
#define pii pair<int, int>
#define pb push_back
#define f first
#define ss second
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define mod2 998244353
const int inf = 1e17 + 1;
#define INT_MAX LLONG_MAX
#define nl "\n"

#define forn(i, a, b) for (int i = a; i < b; i++)
#define forr(i, a, b) for (int i = a; i >= b; i--)
#define input(vec, n) for(int z = 0; z < (n); z++) cin >> vec[z];

void solve() {
    int n; cin>>n;
    vi mp(n);
    vector<vi> mp2(1e5+1);
    forn(i,0,n){
        int a,b; cin>>a>>b;
        mp[i]=a;
        mp2[b].pb(a);
    }
    sort(all(mp));
    for(auto &it:mp2) sort(all(it));
    int q; cin>>q;
    while(q--){
        int a,b; cin>>a>>b;
        int res=upper_bound(all(mp),a)-mp.begin();
        int r2=upper_bound(all(mp2[b]),a)-mp2[b].begin();
        cout<<res-r2<<endl;
    }
}

int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
    int t=1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
0