Submission #524913

#TimeUsernameProblemLanguageResultExecution timeMemory
524913lucriMean (info1cup19_mean)C++17
100 / 100
3 ms588 KiB
#include <iostream> #define int long long using namespace std; int n,a[210][210]; main() { cin>>n; for(int i=1;i<=n;++i) cin>>a[i][i]; for(int l=2;l<=n;++l) { for(int i=1;i+l-1<=n;++i) { /*for(int poz=i;poz+2<=i+l;++poz) { int ma=(a[poz][poz]+a[poz+1][poz+1])/2; if(poz==i&&poz+1==i+l-1) { a[i][i+l-1]=max(a[i][i+l-1],ma); } else if(poz==i) { a[i][i+l-1]=max(a[i][i+l-1],(ma+a[i+2][i+l-1])/2); } else if(poz+1==i+l-1) { a[i][i+l-1]=max(a[i][i+l-1],(ma+a[i][poz-1])/2); } else { a[i][i+l-1]=max(a[i][i+l-1],((ma+a[i][poz-1])/2+a[poz+2][i+l-1])/2); a[i][i+l-1]=max(a[i][i+l-1],((ma+a[poz+2][i+l-1])/2+a[i][poz-1])/2); } }*/ for(int poz=i;poz<i+l-1;++poz) a[i][i+l-1]=max(a[i][i+l-1],(a[i][poz]+a[poz+1][i+l-1])/2); } } cout<<a[1][n]; return 0; }

Compilation message (stderr)

mean.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...