Submission #1036985

#TimeUsernameProblemLanguageResultExecution timeMemory
1036985ivazivaAdvertisement 2 (JOI23_ho_t2)C++14
10 / 100
306 ms25796 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 500001 long long n; vector<pair<long long,long long>> vec; long long f[MAXN],maks[MAXN]; bool cmp(pair<long long,long long> a,pair<long long,long long> b) { if (a.first<b.first) return true; else if (b.first<a.first) return false; else { if (a.second>b.second) return true; else return false; } } int main() { cin>>n; vec.push_back({0,0}); for (long long i=1;i<=n;i++) { long long x,e;cin>>x>>e; vec.push_back({x,e}); } sort(vec.begin(),vec.end(),cmp); for (long long i=1;i<=n;i++) f[i]=vec[i].first-vec[i].second; long long ans=0;maks[1]=f[1]; for (long long i=2;i<=n;i++) { if (f[i]>maks[i-1]) {ans++;maks[i]=f[i];} else maks[i]=maks[i-1]; } cout<<ans+1<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...