# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1123319 | Neco_arc | Advertisement 2 (JOI23_ho_t2) | C++17 | 0 ms | 0 KiB |
#ifndef DEBUG
ios::sync_with_stdio(0), cin.tie(0);
#endif
cin >> n;
REP (i, 0, n) {
cin >> xe[i].FI >> xe[i].SE;
}
sort(xe, xe + n);
REP (i, 0, n) {
ord.pb({xe[i].SE, i});
}
int prv = -1, ptr = 0;
REP (i, 0, n) {
if (xe[i].FI != prv) {
prv = xe[i].FI;
ptr++;
}
inv[ptr] = xe[i].FI;
xe[i].FI = ptr;
}
sort(ALL(ord), greater<ii>());
REP (i, 0, 4 * MAXN) {
add[i] = sub[i] = -INF;
}
for (auto [_, i] : ord) {
auto [x, e] = xe[i];
cerr << x << ' ' << e << ' ' << inv[x] << '\n';
cerr << " ? " << e - inv[x] << ' ' << e + inv[x] << '\n';
int sub = qsub(x, n);
cerr << ' ' << sub << '\n';
if (sub >= e - inv[x]) {
continue;
}
int add = qadd(1, x);
cerr << ' ' << add << '\n';
if (add >= e + inv[x]) {
continue;
}
cerr << " ! " << x << ' ' << e - inv[x] << ' ' << e + inv[x] << '\n';
upd(x, e - inv[x], e + inv[x]);
ans++;
}
cout << ans << '\n';
return 0;
}