結果
| 問題 | No.3085 Easy Problems |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-01-03 22:10:19 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 579 ms / 2,000 ms |
| コード長 | 1,292 bytes |
| 記録 | |
| コンパイル時間 | 4,769 ms |
| コンパイル使用メモリ | 354,728 KB |
| 実行使用メモリ | 25,072 KB |
| 最終ジャッジ日時 | 2026-01-03 22:10:44 |
| 合計ジャッジ時間 | 22,020 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
// 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;
vector<pair<int,int>>a(n);
for(int i=0;i<n;++i){
int x,y;
cin>>x>>y;
a[i]={x,y};
}
vector<array<int,3>>query;
int q;
cin>>q;
int id=0;
for(int i=0;i<q;++i){
int x,y;
cin>>x>>y;
query.push_back({x,y,id++});
}
for(auto [x,y]:a)query.push_back({x,y,id++});
sort(query.begin(),query.end(),[&](array<int,3>&a1, array<int,3>&b){
if(a1[0]!=b[0])return a1[0]<b[0];
if(a1[2]>=q and b[2]>=q){
return a1[1]>b[1];
}
if(a1[2]<q and b[2]<q){
return a1[1]>b[1];
}
if(a1[2]>=q and b[2]<q)return true;
if(a1[2]<q and b[2]>=q)return false;
return a1[2]<b[2];
}
);
int pref=0;
map<int,int>freq;
vector<int>ans(q);
for(auto [x,y,id]:query){
if(id<q){
ans[id] = pref-freq[y];
}
else{
freq[y]++;
pref++;
}
}
for(int i:ans)cout<<i<<endl;
}
signed main(){
fastnuces;
// for(int i=100;i>=1;--i)dfs(i);
//cin>>t;
while(t--){
solve();
}
}
vjudge1