Advertisement
Josif_tepe

Untitled

May 2nd, 2023
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstring>
  4. #include <fstream>
  5. using namespace std;
  6. typedef long long ll;
  7. int main() {
  8.     ios_base::sync_with_stdio(false);
  9.     ifstream cin("input.txt");
  10.     ll n, radius, range;
  11.     cin >> n >> radius >> range;
  12.    
  13.     vector<pair<ll, ll> > v(n);
  14.     for(int i = 0; i < n; i++) {
  15.         cin >> v[i].first >> v[i].second;
  16.     }
  17.     sort(v.begin(),  v.end());
  18.     ll result = 0;
  19. //    cout << v[0].first << endl;
  20. //    cout << v[n - 1].first << endl;
  21.     for(int i = 0; i < n; i++) {
  22.         ll extends = v[i].first + (2 * radius);
  23.         ll take = (v[i].second + range - 1) / range;
  24. //        cout << extends << " "<< v[i + 5].first << endl;
  25. //        break;
  26.         int j = i + 1;
  27.         while(j < n and extends >= v[j].first) {
  28.             take = max((v[j].second + range - 1) / range, take);
  29.             j++;
  30.         }
  31. //        cout << i << " " << j << endl;
  32.  
  33.         i = j - 1;
  34.         result += take;
  35.     }
  36.     cout << result << endl;
  37.     return 0;
  38. }
  39. /*
  40.  4 1 1
  41.  7 1
  42.  8 1
  43.  9 1
  44.  10 1
  45.  
  46.  302917175
  47.  641099008
  48.  **/
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement