Advertisement
Alexandre_lsv

Untitled

Mar 23rd, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define eps 1e-1
  3. typedef long long ll;
  4. using namespace std;
  5. const ll fix=(ll)10e10;
  6. multimap<ll, ll> mmapb;
  7. multimap<ll, ll> mmape;
  8. multimap<ll, ll> mapb;
  9. multimap<ll, ll> mape;
  10. ll sign(ll a){
  11.     return a<0?-1:1;
  12. }
  13. int main(){
  14.     ifstream fin("segments.in");
  15.     ofstream fout("segments.out");
  16.     ll n, m;
  17.     fin >> n >> m;
  18.     ll a, b;
  19.     for (ll i=0; i<n; i++){
  20.         fin >> a >> b;
  21.         mapb.emplace(min(a,b)+fix, 0);
  22.         mape.emplace(max(a,b)+fix, 0);
  23.     }
  24.     ll count=1;
  25.     for (auto&m:mapb){
  26.         mmapb.emplace(m.first, count);
  27.         count++;
  28.     }
  29.     count=1;
  30.     for (auto&m:mape){
  31.         mmape.emplace(m.first, count);
  32.         count++;
  33.     }
  34.     mmape.emplace(0,0);
  35.     mmapb.emplace(0,0);
  36.     for (ll i=0; i<m; i++){
  37.         fin >> a;      
  38.         multimap<ll,ll>::iterator iterb = mmapb.upper_bound(a+fix+eps);
  39.         multimap<ll,ll>::iterator itere = mmape.upper_bound(a+fix-eps);
  40.         iterb--;
  41.         itere--;
  42.         ll res=iterb->second-itere->second;
  43.         fout << res << ' ';
  44.     }
  45.     fin.close();
  46.     fout.close();
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement