Advertisement
leminhkt

noname19 (seq)

Mar 5th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
  5. #define FORn(i, n) for(ll i=1; i<=(n); i++)
  6. #define FORx(i, a, b, n) for(ll i=(a); i<=(b); i+=(x))
  7. #define FORa(i, b) for(i; i<=(b); i++)
  8. #define FORax(i, b, x) for(i; i<=(b); i+=(x))
  9. #define FORR(i, a, b) for(ll i=(a); i>=(b); i--)
  10. #define FORRn(i, n) for(ll i=(n); i>=1; i--)
  11. #define FORRx(i, a, b, n) for(ll i=(a); i>=(b); i-=(x))
  12. #define FORRa(i, b) for(i; i>=(b); i--)
  13. #define FORRax(i, b, x) for(i; i>=(b); i-=(x))
  14. #define pub(a, x) (a).push_back(x)
  15. #define puf(a, x) (a).insert((a).begin(), x)
  16. #define pob(a) (a).pop_back()
  17. #define pof(a) (a).erase((a).begin())
  18. #define all(x) (x).begin(), (x).end()
  19. #define sz(x) (x).size()
  20. #define sqr(x) (x)*(x)
  21. #define PI (2*acos(0))
  22. using namespace std;
  23.  
  24. struct cow
  25. {
  26.     int p, h;
  27. };
  28. int n, d, res, j=1;
  29. bool tc(cow a, cow b){
  30.     return a.p<b.p;
  31. }
  32. int main(){
  33.     // freopen("INPUT.inp", "r", stdin);
  34.     // freopen("OUTPUT.out", "w", stdout);
  35.     // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  36.     cin>>n>>d;
  37.     vector<cow> a(n, {0, 0});
  38.     vector<bool> m(n, 0);
  39.     for(cow &i:a) cin>>i.p>>i.h;
  40.     sort(all(a), tc);
  41.     FOR(i, 0, n-3) FOR(j, i+1, n-2) if(a[j].p-a[i].p<=d){
  42.         if(2*a[j].h<=a[i].h) m[j]=1;
  43.     }
  44.     else break;
  45.     j=n-2;
  46.     FORR(i, n-1, 2) FORR(j, i-1, 1) if(a[i].p-a[j].p<=d){
  47.         if(2*a[j].h<=a[i].h&&m[j]==1) res++, m[j]=0;
  48.     }
  49.     else break;
  50.     cout<<res;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement