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
using ll = long long;
using pii = pair<int,int>;
#define elif else if
#define dbg(v)\
cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl;
inline int readInt() {
int x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') ch = getchar_unlocked();
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return x;
}
bool cover(pii a, pii b){
return abs(a.first-b.first) <= a.second-b.second;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n = readInt();
pii arr[n];
for(int i = 0; i < n; i++){
arr[i].first = readInt();
arr[i].second = readInt();
}
sort(arr, arr+n);
vector<pii> v;
for(int i = 0; i < n; i++){
while(!v.empty() && cover(arr[i], v.back())) v.pop_back();
if(v.empty() || (!cover(arr[i], v.back()) && !cover(v.back(), arr[i]))) v.push_back(arr[i]);
}
cout << v.size();
return 0;
}
# | 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... |