#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
class Node;
using namespace __gnu_pbds;
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) (c).begin(), (c).end()
//#define int long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define sz(a) (int)a.size()
// permutation of the last layer
#define LOO(i,a,b) for (int i = a; i <= b; i++)
#define OOL(i,a,b) for (int i = b; i >= a; i--)
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
#define ld long double
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("avx2")
using namespace std;
typedef tree<int,null_type, less_equal<>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
typedef tree<int,null_type, less<>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
constexpr ll MAX = 1e9+7;
void iO() {
freopen("haircut.out", "w",stdout);
freopen("haircut.in", "r",stdin);
}
vector<int> make_sorted_index(vector<auto> const &values) {
vector<int> index(values.size());
iota(index.begin(), index.end(), 0);
stable_sort(index.begin(), index.end(), [&values](auto a, auto b) {
return values[a] < values[b];
});
return index;
} // this function is so skibidi
struct chash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
int operator()(pii x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();return splitmix64(FIXED_RANDOM * x.first + x.second + FIXED_RANDOM);
}
}; // gp_hash_table custom hash so skibid
void solve() {
int n;
cin>>n;
vector<pll> a(n);
LOO(i,0,n-1) cin>>a[i].F>>a[i].S;
sort(all(a));
a.erase(unique(all(a)), a.end());
ll answ = 0;
multiset<ll> cooder;
multiset<ll> uncooder;
n = sz(a);
LOO(i,0,n-1) {
cooder.insert(a[i].F-a[i].S);
}
LOO(i,0,n-1) {
cooder.erase(cooder.find(a[i].F-a[i].S));
if (cooder.upper_bound(a[i].F-a[i].S)==cooder.begin() && uncooder.lower_bound(a[i].F+a[i].S)==uncooder.end()) {
answ++;
}
uncooder.insert(a[i].F+a[i].S);
}
cout << answ;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// iO();
int t = 1;
// cin >> t;
while (t--) {
solve();
// cout << flush;
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'void iO()':
Main.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen("haircut.out", "w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen("haircut.in", "r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |