結果

問題 No.3085 Easy Problems
ユーザー ococonomy1
提出日時 2025-04-04 21:25:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 2,393 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 201,180 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2025-04-04 21:25:47
合計ジャッジ時間 11,341 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'
#define YESNO(x) ((x) ? "Yes" : "No")
#define YES YESNO(true)
#define NO YESNO(false)
#define REV_PRIORITY_QUEUE(tp) priority_queue<tp,vector<tp>,greater<tp>>
#define NO_ANS(x) {cout << (x) << '\n'; return;}
template <typename T>
void inline VEC_UNIQ(vector<T> &v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    return;
}

#define MULTI_TEST_CASE false
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
    //複数の解法のアイデアを思いついた時は全部メモしておく
    //g++ -D_GLIBCXX_DEBUG -Wall -Wextra -O2 c.cpp -o o
    int n;
    cin >> n;
    vector<ll> difficulty(n);
    const int m = 100000;
    vector<vector<ll>> buxnya_dif(m);
    for(int i = 0; i < n; i++){
        ll a;
        int b;
        cin >> a >> b;
        b--;
        difficulty[i] = a;
        buxnya_dif[b].push_back(a);
    }
    sort(difficulty.begin(),difficulty.end());
    for(int i = 0; i < m; i++){
        sort(buxnya_dif[i].begin(),buxnya_dif[i].end());
    }

    int q;
    cin >> q;
    while(q--){
        ll x;
        int y;
        cin >> x >> y;
        y--;
        int ans = distance(difficulty.begin(),upper_bound(difficulty.begin(),difficulty.end(),x));
        ans -= distance(buxnya_dif[y].begin(),upper_bound(buxnya_dif[y].begin(),buxnya_dif[y].end(),x));
        cout << ans << el;
    }
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0