Submission #208036

#TimeUsernameProblemLanguageResultExecution timeMemory
208036rzbtSplit the sequence (APIO14_sequence)C++14
28 / 100
2100 ms91720 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 100005 #define MAXK 205 typedef long long ll; using namespace std; ll n,u; ll dp[MAXN][MAXK]; ll niz[MAXN]; ll suma[MAXN]; ll sec[MAXN][MAXK]; pair<ll,ll> prava[MAXN][MAXK]; vector<pair<pair<ll,ll>,ll> > prave; int main() { scanf("%lld %lld", &n, &u); for(ll i=1;i<=n;i++) scanf("%lld",niz+i); for(ll i=1;i<=n;i++) suma[i]=suma[i-1]+niz[i]; for(ll k=1;k<=u;k++){ prave.clear(); for(ll d=k+1;d<=n;d++){ //while(!prave.empty()) for(ll i=k+1;i<=d;i++){ ll tr=suma[i-1]*(suma[d]-suma[i-1])+dp[i-1][k-1]; if(tr>dp[d][k]){ sec[d][k]=i-1; dp[d][k]=tr; } } //printf(" %lld %lld %lld\n",d,k,dp[d][k]); } } printf("%lld\n",dp[n][u]); ll poc=n; for(ll i=u;i>0;i--){ poc=sec[poc][i]; printf("%lld ",poc); } return 0; }

Compilation message (stderr)

sequence.cpp: In function 'int main()':
sequence.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &n, &u);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sequence.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",niz+i);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...