結果

問題 No.3085 Easy Problems
コンテスト
ユーザー vjudge1
提出日時 2026-01-03 17:44:09
言語 C++11(廃止可能性あり)
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 741 ms / 2,000 ms
コード長 945 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,758 ms
コンパイル使用メモリ 193,724 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2026-01-03 17:44:38
合計ジャッジ時間 22,995 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:23:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   23 |     for(auto &[aa,bb]:b_categ){
      |               ^

ソースコード

diff #
raw source code

// Source: https://usaco.guide/general/io
//who needs macros when you have usaco
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define fastnuces ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t = 1;



void solve(){
	int n;
    cin>>n;
    map<int,vector<int>>b_categ;
    vector<int>a(n);
    for(int i=0;i<n;++i){
        int x,y;
        cin>>x>>y;
        a[i]=x;
        b_categ[y].push_back(x);
    }
sort(a.begin(),a.end());
    for(auto &[aa,bb]:b_categ){
        sort(bb.begin(),bb.end());
    }

    int q;
    cin>>q;
    while(q--){
        int aa,bb;
        cin>>aa>>bb;

        int total = upper_bound(a.begin(),a.end(),aa)-a.begin();

        int equal = upper_bound(b_categ[bb].begin(),b_categ[bb].end(),aa)-b_categ[bb].begin();
        cout<<total-equal<<endl;
    }

    
}

signed main(){

    fastnuces;
   // for(int i=100;i>=1;--i)dfs(i);
    //cin>>t;

    while(t--){
        solve();
    }
}
0