Submission #1101478

# Submission time Handle Problem Language Result Execution time Memory
1101478 2024-10-16T08:53:26 Z nhutran K blocks (IZhO14_blocks) C++14
0 / 100
9 ms 63828 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define is insert
#define ed end()
#define fi first
#define se second
#define bg begin()
#define pb push_back
#define vll vector <ll>
#define mask(k) (1<<(k))
#define mll map <ll, ll>
#define pll pair <ll, ll>
#define ppl pair <ll, pll>
using namespace std;

ll n,k,i,j,pos,l,r,mid;
int f[4005][4005],p;
int a[400005];
int dp[4001][4001];
int b[4001][4001];
ll ans,m;

int get(ll l, ll r)
{
    ll k=__lg(r-l+1);
    return (b[l][k]+b[r-mask(k)+1][k]);
}

int main()
{
    cin>>n>>m;
    for (i=1; i<=n; i++)
    {
        cin>>a[i];
        b[i][0]=a[i];
    }
    for (j=1; mask(j)<=n; j++)
        for (i=1; i+mask(j)-1<=n; i++)
            b[i][j]=(b[i][j-1]+b[i+mask(j-1)][j-1]);
    memset(dp,0x3f,sizeof dp);
    dp[0][0]=0;
    for (i=1; i<=m; i++)
        for (j=1; j<=n; j++)
        {
            for (k=1; k<=j; k++)
                dp[i][j]=min(dp[i][j],dp[i-1][k-1]+get(k,j));
        }
    cout<<dp[m][n];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 63824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 63828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 63824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 63824 KB Output isn't correct
2 Halted 0 ms 0 KB -