제출 #1324916

#제출 시각아이디문제언어결과실행 시간메모리
1324916behradAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
110 ms4332 KiB
#ifdef LOCAL
#include "/home/bgopc/template/pch.hpp"
#endif
#include <bits/stdc++.h>
using namespace std;
// * No One Dies a Virgin, Life Fucks Us All
typedef long long ll;
#define nl '\n'
#define ff first
#define ss second
#define pb push_back
#define sik(x) {cout << x << nl; return;}
constexpr ll maxn = 5e5+10, mod = 1e9 + 7, inf = 1e17, SQ = 450, LG = 20;
typedef pair<int, int> pii;

int n;
pii a[maxn];

int32_t main() {
  cin.tie(0)->sync_with_stdio(0); 
  cin >> n;
  for (int i = 1 , x , e ; i <= n ; i ++) {
    cin >> x >> e;
    a[i] = {x - e, x + e};
  }

  sort(a + 1, a + n + 1, [&] (const pii& x, const pii& y) {
    if (x.ff == y.ff) return x.ss > y.ss;
    else return x.ff < y.ff;
  });

  int ans = 0;
  ll r = -inf;
  for (int i = 1 ; i <= n ; i ++) {
    if (a[i].ss > r) {
      ++ ans;
      r = a[i].ss;
    }
  }
  cout << ans << nl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...