Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define eps 1e-1
- typedef long long ll;
- using namespace std;
- const ll fix=(ll)10e10;
- multimap<ll, ll> mmapb;
- multimap<ll, ll> mmape;
- multimap<ll, ll> mapb;
- multimap<ll, ll> mape;
- ll sign(ll a){
- return a<0?-1:1;
- }
- int main(){
- ifstream fin("segments.in");
- ofstream fout("segments.out");
- ll n, m;
- fin >> n >> m;
- ll a, b;
- for (ll i=0; i<n; i++){
- fin >> a >> b;
- mapb.emplace(min(a,b)+fix, 0);
- mape.emplace(max(a,b)+fix, 0);
- }
- ll count=1;
- for (auto&m:mapb){
- mmapb.emplace(m.first, count);
- count++;
- }
- count=1;
- for (auto&m:mape){
- mmape.emplace(m.first, count);
- count++;
- }
- mmape.emplace(0,0);
- mmapb.emplace(0,0);
- for (ll i=0; i<m; i++){
- fin >> a;
- multimap<ll,ll>::iterator iterb = mmapb.upper_bound(a+fix+eps);
- multimap<ll,ll>::iterator itere = mmape.upper_bound(a+fix-eps);
- iterb--;
- itere--;
- ll res=iterb->second-itere->second;
- fout << res << ' ';
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement