Submission #824451

#TimeUsernameProblemLanguageResultExecution timeMemory
824451devariaotaLightning Rod (NOI18_lightningrod)C++17
54 / 100
2051 ms156256 KiB
# include <bits/stdc++.h> # define int long long # define vi vector<int> # define pb push_back # define pii pair<int, int> # define fi first # define se second # define endl '\n' # define jess ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; int n, x[10000005], y[10000005]; set<pii> s; void solve() { cin >> n; bool ok=1; int mx=0, mn=1e9; for(int i=1; i<=n; i++) { cin >> x[i] >> y[i]; if(y[i]!=1) ok=0; mx=max(mx, y[i]); mn=min(mn, y[i]); } if(ok) { cout << n << endl; return; } if((mx-mn)<=1) { int cnt=0; for(int i=1; i<=n; i++) { if(y[i]==1) cnt++; else { if(y[i-1]!=1 && y[i+1]!=1) cnt++; } } cout << cnt << endl; return; } for(int i=1; i<=n; i++) { s.insert({y[i], x[i]}); } int ans=0; while(!s.empty()) { pii cur=*s.rbegin(); ans++; vector<pii> v; for(pii i : s) { if(abs(i.se-cur.se)<=(cur.fi-i.fi)) { v.pb(i); } } for(pii i : v) s.erase(i); } cout << ans << endl; } signed main() { jess; solve(); }
#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...