Submission #265527

# Submission time Handle Problem Language Result Execution time Memory
265527 2020-08-15T00:06:28 Z tko919 Split the sequence (APIO14_sequence) C++17
0 / 100
7 ms 1920 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

ll dp[201][1010]={},pre[1010][201];

int main(){
   int n,k; cin>>n>>k;
   if(n>1000)return 0;
   vector<ll> a(n),rui(n+1);
   rep(i,0,n){
      cin>>a[i]; rui[i+1]=a[i];
   }
   rep(i,0,n)rui[i+1]+=rui[i];
   rep(j,0,k+1)rep(i2,0,n)dp[j][i2]=-INF;
   dp[0][0]=0;
   rep(i,0,n)rep(j,0,k+1)rep(i2,0,i+1)if(dp[j][i2]>=0){
      if(j==k)continue;
      ll add=(rui[i+1]-rui[i2])*(rui[n]-rui[i+1]);
      if(chmax(dp[j+1][i+1],dp[j][i2]+add))pre[i+1][j]=i2;
   }
   ll res=-INF;
   rep(j,0,n+1)chmax(res,dp[k][j]);
   cout<<res<<endl;
   int pos=n,cur=k-1; vector<int> ps;
   while(cur>=0){
      pos=pre[pos][cur];
      ps.push_back(pos); cur--;
   }
   reverse(ALL(ps));
   rep(i,0,k)cout<<ps[i]+1<<endl;
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB contestant found the optimal answer: 108 == 108
2 Incorrect 0 ms 384 KB declared answer doesn't correspond to the split scheme: declared = 999, real = 719
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Integer 50 violates the range [1, 49]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 640 KB declared answer doesn't correspond to the split scheme: declared = 610590000, real = 507121050
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1920 KB declared answer doesn't correspond to the split scheme: declared = 21503404, real = 21169074
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -