Submission #1268267

#TimeUsernameProblemLanguageResultExecution timeMemory
1268267julia_08Advertisement 2 (JOI23_ho_t2)C++20
59 / 100
2 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e3 + 10;

int x[MAXN], e[MAXN];

int deg[MAXN];

int main(){
  cin.tie(0)->sync_with_stdio(0);

  int n; cin >> n;

  for(int i=0; i<n; i++) cin >> x[i] >> e[i];

  vector<pair<pair<int, int>, int>> r;

  for(int i=0; i<n; i++) r.push_back({{x[i], e[i]}, i});

  sort(r.begin(), r.end());
    
  vector<int> to_erase;

  int last_x = -1, last_e = -1;

  for(int i=0; i<n; i++){

    if(r[i].first.first == last_x && r[i].first.second == last_e){
      to_erase.push_back(i);
    }

    last_x = r[i].first.first;
    last_e = r[i].first.second;

  }

  while(!to_erase.empty()){
    swap(r[to_erase.back()], r.back());
    r.pop_back();
    to_erase.pop_back();
  }

  n = r.size();

  for(int i=0; i<n; i++){
    x[i] = r[i].first.first;
    e[i] = r[i].first.second;
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){

      if(j == i) continue;

      if(abs(x[i] - x[j]) <= e[i] - e[j]) deg[j] ++;

    }
  }

  int ans = 0;

  for(int i=0; i<n; i++) ans += (deg[i] == 0);

  cout << ans << "\n";

  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...