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;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,a,b,big = -1,br = 0;
cin >> n;
vector<pair<int,int>> haha(0);
priority_queue<int> idk;
for(int i = 0; i < n; i++) {
cin >> a >> b;
haha.push_back({a,b});
}
sort(haha.begin(),haha.end());
for(int i = 0; i < n; i++) {
if(haha[i].first+haha[i].second > big) {
big = haha[i].first+haha[i].second;
br++;
while(!idk.empty() && idk.top() >= haha[i].first-haha[i].second) {
idk.pop();
br--;
}
idk.push(haha[i].first-haha[i].second);
}
}
cout << br;
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... |