Submission #829020

#TimeUsernameProblemLanguageResultExecution timeMemory
829020makanhuliaLightning Rod (NOI18_lightningrod)C++17
14 / 100
1839 ms157608 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); ll x, y; for(int i=0; i<n; i++){ cin >> x >> y; seg[i] = mp(x-y, x+y); } sort(seg.begin(), seg.end(), comp); ll r=0, R=0, cnt = 0; for(int i=0; i<n; i++){ R = max(r, seg[i].se); if(seg[i].se > r){ ++cnt; r = R; } } 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...