Submission #379921

#TimeUsernameProblemLanguageResultExecution timeMemory
379921rocks03Lightning Rod (NOI18_lightningrod)C++14
80 / 100
2078 ms243820 KiB
//#pragma GCC target("avx2") //#pragma GCC optimization("O3") //#pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve(){ int N; cin >> N; vector<int> x(N), y(N); rep(i, 0, N) cin >> x[i] >> y[i]; deque<int> q; q.push_back(0); rep(i, 1, N){ while(SZ(q) && x[i] - y[i] <= x[q.back()] - y[q.back()]) q.pop_back(); q.push_back(i); } int ans = 0; while(SZ(q)){ int v = q[0]; q.front(); ans++; while(SZ(q) && x[v] + y[v] >= x[q[0]] + y[q[0]]){ q.pop_front(); } } cout << ans; } int main(){ ios_base::sync_with_stdio(false), cin.tie(nullptr); solve(); 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...