Submission #81838

#TimeUsernameProblemLanguageResultExecution timeMemory
81838tmwilliamlin168Lightning Conductor (POI11_pio)C++14
72 / 100
1080 ms9708 KiB
#include <bits/stdc++.h> using namespace std; inline int in() { int r=0; char ch=getchar_unlocked(); while(1) { if(ch>='0'&&ch<='9') break; ch=getchar_unlocked(); } r=ch-'0'; while(1) { ch=getchar_unlocked(); if (ch<'0'||ch>'9') break; r=r*10+ch-'0'; } return r; } inline void out(int x) { if(!x) { putchar_unlocked('0'); return; } int r=x, c=0; while(!(r%10)) { ++c; r/=10; } r=0; while(x) { r=r*10+x%10; x/=10; } while(r) { putchar_unlocked(r%10+'0'); r/=10; } while(c--) putchar_unlocked('0'); } 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); n=in(); for(int i=0; i<n; ++i) { a1[i+1]=max(a[i]=h[i]=in(), 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) { out(max(a1[i+1], a2[i])-h[i]); putchar_unlocked('\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...