Submission #870479

#TimeUsernameProblemLanguageResultExecution timeMemory
870479imarnAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
154 ms25004 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,ll> #define pll pair<ll,ll> #define all(x) x.begin(),x.end() #define pb push_back #define sz(x) (int)x.size() #define f first #define s second using namespace std; bool cmp(pair<ll,pii> a,pair<ll,pii> b){ if(a.f==b.f)return a.s.s-a.s.f<b.s.s-b.s.f; return a.f<b.f; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); ll n;cin>>n; vector<pair<ll,pii>>q; for(int i=0;i<n;i++){ int si,ti;cin>>si>>ti; q.pb({si+ti,{si,ti}}); }sort(q.begin(),q.end(),cmp); stack<ll>st; for(int i=0;i<n;i++){ while(!st.empty()&&st.top()<=q[i].s.s-q[i].s.f)st.pop(); st.push(q[i].s.s-q[i].s.f); }cout<<st.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...