# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789930 | shoryu386 | Advertisement 2 (JOI23_ho_t2) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define getchar_unlocked _getchar_nolock
inline int readint() {
int x = 0;
char ch = getchar_unlocked();
while (ch < '0' || ch > '9')
ch = getchar_unlocked();
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar_unlocked();
}
return x;
}
main(){
int n = readint();
pair<int, int> arr[n];
for (int x = 0; x < n; x++) arr[x].first = readint(), arr[x].second = readint(), arr[x] = make_pair(arr[x].first - arr[x].second, -(arr[x].first + arr[x].second));
sort(arr, arr+n);
int prevY = LLONG_MIN/10;
int ans = 0;
for (int x = 0; x < n; x++){
arr[x].second = -arr[x].second;
if (arr[x].second > prevY){
ans++;
prevY = arr[x].second;
}
}
cout << ans;
}