Submission #81837

#TimeUsernameProblemLanguageResultExecution timeMemory
81837tmwilliamlin168Lightning Conductor (POI11_pio)C++14
81 / 100
1075 ms36812 KiB
#include <bits/stdc++.h> using namespace std; const int mxN=5e5; int n, h[mxN], a[mxN], a1[mxN+1], a2[mxN+1]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=0; i<n; ++i) { cin >> h[i]; a1[i+1]=max(a[i]=h[i], a1[i]); for(int j=0; i-j*j-1>=0; ++j) a1[i+1]=max(++a[i-j*j-1], a1[i+1]); } for(int i=n-1; i>=0; --i) { a2[i]=max(a[i]=h[i], a2[i+1]); for(int j=0; i+j*j+1<=n-1; ++j) a2[i]=max(++a[i+j*j+1], a2[i]); } for(int i=0; i<n; ++i) cout << max(a1[i+1], a2[i])-h[i] << "\n"; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...