Submission #933656

#TimeUsernameProblemLanguageResultExecution timeMemory
933656carriewangAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
125 ms19404 KiB
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define pii pair<int,int> #define pll pair<ll,ll> #define sz(x) x.size() #define all(x) x.begin(),x.end() #define F first #define S second using namespace std; const int maxn=500005; int n; pii p[maxn]; vector<pii> ans; bool compare(pii a,pii b){ if(abs(b.first-a.first)<=b.second-a.second) return 1; return 0; } int main(){ ios::sync_with_stdio(0),cin.tie(0); cin >> n; for(int i=0;i<n;i++){ cin >> p[i].F >> p[i].S; } sort(p,p+n); for(int i=0;i<n;i++){ if(ans.empty()) ans.emplace_back(p[i]); else{ if(!compare(p[i],ans.back())){ while(!ans.empty() && compare(ans.back(),p[i])) ans.pop_back(); ans.emplace_back(p[i]); } } } cout << ans.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...