結果
| 問題 | No.3085 Easy Problems |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-26 23:43:17 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 491 ms / 2,000 ms |
| コード長 | 1,609 bytes |
| 記録 | |
| コンパイル時間 | 3,280 ms |
| コンパイル使用メモリ | 291,616 KB |
| 実行使用メモリ | 17,752 KB |
| 最終ジャッジ日時 | 2025-12-26 23:43:40 |
| 合計ジャッジ時間 | 21,262 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define double long double
#define float double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define nl '\n'
#define here cout << "HERE" << endl;
#define forn(i, a, n) for (int i = a; i < n; i++)
#define print(a) for (auto& e : a) cout << e << " "; cout << endl;
#define MOD(a, b) (((a) % (b) + (b)) % (b))
#define yesno(b) cout << ((b) ? "YES\n" : "NO\n")
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using vi = vector<int>;
// sort challenges and find lower bound to get number of possible challenges
// get upper bound of challenges array
// difference is answer
void solve(){
int n;
cin>>n;
vector<pair<int,int>> challenges(n);
vector<vi> arr(2e5);
forn(i,0,n){
cin>>challenges[i].first>>challenges[i].second;
}
sort(all(challenges));
forn(i,0,n){
arr[challenges[i].second].pb(challenges[i].first);
}
for(auto &array:arr){
if(!arr.empty())sort(all(array));
}
int q;
cin>>q;
vector<pair<int,int>> heros(q);
forn(i,0,q){
cin>>heros[i].first>>heros[i].second;
int total=lower_bound(all(challenges),make_pair(heros[i].first,LLONG_MAX))-challenges.begin();
int cantdo=upper_bound(all(arr[heros[i].second]),heros[i].first) - arr[heros[i].second].begin();
cout<<total-cantdo<<endl;
}
}
// 1 3
// 2 3
// 3 2
// 5 1
// 10 2
// 1 3
// 2 3
signed main(){
fast
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}