Submission #652832

#TimeUsernameProblemLanguageResultExecution timeMemory
652832raysh07Lightning Rod (NOI18_lightningrod)C++14
21 / 100
1467 ms262144 KiB
#include <bits/stdc++.h> using namespace std; #define int long long mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); void Solve() { int n; cin>>n; int x[n]; int y[n]; for (int i=0; i<n; i++) cin>>x[i]>>y[i]; int c = 0; int last = 0; for (int i = 1; i<n; i++) { if (x[i]-x[last]<=y[i]-y[last]) { } else { c++; i--; int p = x[i]; int q = y[i]; for (int j=i; j<n; j++) { if (x[j]-p<=q-y[j]) { i = j; last = j+1; } else break; } } } if (last!=n) c++; cout<<c<<"\n"; } int32_t main() { //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\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...