結果
| 問題 | No.3085 Easy Problems |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-01-03 19:46:44 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 262 ms / 2,000 ms |
| コード長 | 4,179 bytes |
| 記録 | |
| コンパイル時間 | 5,183 ms |
| コンパイル使用メモリ | 359,524 KB |
| 実行使用メモリ | 17,488 KB |
| 最終ジャッジ日時 | 2026-01-03 19:47:02 |
| 合計ジャッジ時間 | 16,017 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
//Maqsad Nahi Bhoolna
#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 min_heap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using max_heap = priority_queue<T>;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//find_by_order(k): returns iterator to k-th smallest element (0-based)
//order_of_key(x): returns number of elements strictly less than x
#define ll long long int
#define ld long double
#define nl cout<<"\n"
#define re return 0
#define fs first
#define sc second
#define MOD 1000000007
#define pii pair<ll,ll>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vpii vector<pair<ll,ll>>
#define vvpii vector<vector<pair<ll,ll>>>
#define vb vector<bool>
#define vbb vector<vector<bool>>
#define us unordered_set<ll>
#define all(vec) vec.begin(), vec.end()
#define allr(vec) vec.rbegin(), vec.rend()
#define sahi(vec) sort(vec.begin(),vec.end())
#define ulta(vec) sort(vec.begin(),vec.end(),greater<typename decltype(vec)::value_type>())
#define fori(a,b) for(ll i=a;i<b;i++)
#define forj(a,b) for(ll j=a;j<b;j++)
#define fork(a,b) for(ll k=a;k<b;k++)
#define forr(a,b) for(ll r=a;r>=b;r--)
#define yes(expr) (expr)? cout<<"yes" : cout<<"no"
#define Yes(expr) (expr)? cout<<"Yes" : cout<<"No"
#define YES(expr) (expr)? cout<<"YES" : cout<<"NO"
#define print(vec) for(auto x : vec) cout<<x<<" "
#define io ios_base::sync_with_stdio(false);cin.tie(nullptr)
template <typename A, typename B>
istream& operator>>(istream &in, pair<A,B> &p) {
in >> p.first >> p.second;
return in;
}
template <typename T>
istream& operator>>(istream &in, vector<T> &v) {
for (auto &x : v) in >> x;
return in;
}
template <typename A, typename B>
istream& operator>>(istream &in, vector<pair<A,B>> &vp) {
for (auto &p : vp) in >> p.first >> p.second;
return in;
}
template <typename A, typename B>
ostream& operator<<(ostream &out, const pair<A,B> &p) {
out << p.first << " " << p.second;
return out;
}
template <typename T>
ostream& operator<<(ostream &out, const vector<T> &v) {
for (auto &x : v) out << x << " ";
return out;
}
template <typename A, typename B>
ostream& operator<<(ostream &out, const vector<pair<A,B>> &vp) {
for (auto &p : vp) out << p.first << " " << p.second << "\n";
return out;
}
vb is_prime;
void sieve(ll n) {
is_prime.assign(n+1,true);
is_prime[0] = is_prime[1] = false;
for(ll i=2;i*i<=n;i++) {
if(is_prime[i]) {
for(ll j=i*i;j<=n;j+=i)
is_prime[j] = false;
}
}
}
bool isprime(ll n) {
if(n<2) return false;
if(n==2 || n==3) return true;
if(n%2==0 || n%3==0) return false;
for(ll i=5;i*i<=n;i+=6)
{
if(n%i==0 || n%(i+2)==0)
return false;
}
return true;
}
ll nextprime(ll n) { return (isprime(n))? n : nextprime(n+1); }
ll sum_digits(ll n) { return (n<10)? n : n%10 + sum_digits(n/10); }
ll gcd(ll a, ll b) { return (b==0)? a : gcd(b,a%b); }
ll lcm(ll a, ll b) { return (a*b)/gcd(a,b); }
int main()
{
io;
ll n;
cin>>n;
vpii arr(n);
cin>>arr;
ll x;
cin>>x;
vpii uss(x);
cin>>uss;
sahi(arr);
vl bin(n);
fori(0,n)
bin[i] = arr[i].fs;
vpii count(n);
fori(0,n)
{
count[i].fs = arr[i].sc;
count[i].sc = arr[i].fs;
}
sahi(count);
vl type(n);
fori(0,n)
type[i] = count[i].fs;
vl value(n);
fori(0,n)
value[i] = count[i].sc;
function<ll(ll,ll)> f = [&](ll cur, ll z) {
auto it1 = lower_bound(all(type),z);
auto it2 = upper_bound(all(type),z);
ll d1 = it1-type.begin();
ll d2 = it2-type.begin();
auto it3 = upper_bound(value.begin()+d1,value.begin()+d2,cur);
ll now = it3-(value.begin()+d1);
return now;
};
fori(0,x)
{
auto it = upper_bound(all(bin),uss[i].fs);
ll d = it-bin.begin();
ll z = uss[i].sc;
cout<<d-f(uss[i].fs,z);
nl;
}
return 0;
}
vjudge1