https://i0.wp.com/eblogarithm.com/wp-content/uploads/2017/07/Tinkoff-Challenge--Final-Round-Codeforces-Round-414-rated-Div-1--Div-2-problem-E-Choosing-Carrot-Solution-In-CC1.png?fit=640%2C360

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

#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;
return 0;
}

(Visited 3 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: