Tinkoff Challenge – Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2), problem: (E) Choosing Carrot Solution In C/C++

By | 2017-07-24T16:40:56+00:00 July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , , |

#include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<cmath> #include<cstring> #include<cstdlib> using namespace std; int a[333333],b[333333]; int main() { int n,i,x,y; cin>>n; for(i=1;i<=n;i=i+1) cin>>a[i]; for(i=1;i<=n;i=i+1) { x=(i-1)-(n-i); if(x<0) x=-x; b[x]=max(b[x],a[i]); } for(i=1;i<n;i=i+1) { x=(i-1)-(n-i-1); if(x<0) x=-x; b[x]=max(b[x],min(a[i],a[i+1])); } for(i=2;i<=n;i=i+1) b[i]=max(b[i],b[i-2]); for(i=1;i<n;i=i+1) cout<<b[i]<<' '; cout<<b[n-1]<<endl; [...]