Submission #944534

#TimeUsernameProblemLanguageResultExecution timeMemory
944534vladiliusAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
121 ms19660 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
struct node{
    int x, e;
};
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n; cin>>n;
    vector<node> t(n + 1);
    for (int i = 1; i <= n; i++){
        cin>>t[i].x>>t[i].e;
    }
    auto cmp = [&](node a, node b){
        return a.x < b.x;
    };
    sort(t.begin() + 1, t.end(), cmp);
    vector<int> d(n + 1), s(n + 1);
    for (int i = 1; i <= n; i++){
        d[i] = t[i].e - t[i].x;
        s[i] = t[i].e + t[i].x;
    }
    vector<int> st;
    for (int i = 1; i <= n; i++){
        if (st.empty()){
            st.push_back(i);
            continue;
        }
        while (!st.empty() && t[i].x - t[st.back()].x <= t[i].e - t[st.back()].e){
            st.pop_back();
        }
        if (st.empty() || !((t[i].x - t[st.back()].x) <= t[st.back()].e - t[i].e)){
            st.push_back(i);
        }
    }
    cout<<st.size()<<"\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...