Submission #829015

#TimeUsernameProblemLanguageResultExecution timeMemory
829015devariaotaLightning Rod (NOI18_lightningrod)C++17
4 / 100
2060 ms190732 KiB
#include <bits/stdc++.h> typedef long long ll; #define ii pair<ll,ll> #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; vector<ii> seg; bool comp(ii a, ii b){ if(a.fi == b.fi) return a.se > b.se; return a.fi < b.fi; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; seg.resize(n+1); ll x, y; for(int i=1; i<=n; i++){ cin >> x >> y; seg[i] = mp(x-y, x+y); } sort(seg.begin()+1, seg.begin()+n+1, comp); priority_queue<ll> pq; ll r=0, cnt = 0; for(int i=1; i<=n; i++){ // cout<<seg[i].fi<<' '<<seg[i].se<<'\n'; pq.push(seg[i].se); if(seg[i].se > r){ ++cnt; r = pq.top(); pq.pop(); } } cout << cnt << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...