This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#define int long long
using namespace std;
const int inf=1e18,lg=30,mx=5e6,minf=-1e9,mxn=2e5+10,mod=1e9+7;
int32_t main(){
fastio
int n;cin>>n;
vector<vector<int>>dp(n,vector<int>(n,0));
for(int i=0;i<n;i++)cin>>dp[i][i];
for(int sz=0;sz<n;sz++)for(int l=0,r=sz;r<n;l++,r++){
for(int k=l+1;k<=r;k++)dp[l][r]=max(dp[l][r],(dp[l][k-1]+dp[k][r])/2);
}
cout<<dp[0][n-1];
}
/*
*/
Compilation message (stderr)
mean.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
32 | #pragma GCC optimize ("03,unroll-lopps")
| ^
mean.cpp:36:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
36 | int32_t main(){
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |