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>
# define int long long
# define vi vector<int>
# define pb push_back
# define pii pair<int, int>
# define fi first
# define se second
# define endl '\n'
# define jess ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n;
set<pii> s;
void solve() {
cin >> n;
bool ok=1;
for(int i=1; i<=n; i++) {
int x, y;
cin >> x >> y;
if(y!=1) ok=0;
s.insert({y, x});
}
if(ok) {
cout << n << endl;
return;
}
int ans=0;
while(!s.empty()) {
pii cur=*s.rbegin();
ans++;
vector<pii> v;
for(pii i : s) {
if(abs(i.se-cur.se)<=(cur.fi-i.fi)) {
v.pb(i);
}
}
for(pii i : v) s.erase(i);
}
cout << ans << endl;
}
signed main() {
solve();
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |