Submission #229713

#TimeUsernameProblemLanguageResultExecution timeMemory
229713blacktulipMean (info1cup19_mean)C++17
100 / 100
16 ms1664 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define int long long #define se second #define mp make_pair #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 405; const lo mod = 1000000007; int n,m,b[li],a[li],flag,t,PS[li],dp[li][li]; int cev; string s; vector<int> v; inline int f(int l,int r){ int cevv=0; //~ if(r-l<2)return 0; //~ cout<<l<<" : : "<<r<<endl; if(r-l==1)return (a[r]+a[l])/2; if(r-l==0)return a[r]; if(~dp[l][r])return dp[l][r]; //~ if(l==r-1)return 0; //~ cout<<l<<r<<endl; int cev1=0; int yess=1; for(int i=l;i<r;i++){ cev1+=a[i]; yess*=2; } for(int i=l+1;i<r;i++){ cevv=max(cevv,(f(l,i)+(f(i+1,r)))/2); cevv=max(cevv,(f(l,i-1)+(f(i,r)))/2); } yess/=2; return dp[l][r]=(cevv); } main(void){ memset(dp,-1,sizeof(dp)); scanf("%lld",&n); FOR{ scanf("%lld",&a[i]); PS[i]=PS[i-1]+a[i]; } printf("%lld\n",f(1,n)); return 0; }

Compilation message (stderr)

mean.cpp:54:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
mean.cpp: In function 'int main()':
mean.cpp:56:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
mean.cpp:58:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...