# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1077775 | ntdaccode | K blocks (IZhO14_blocks) | C++17 | 1076 ms | 9072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int mod=1e9+7;
const int M=1e4+10;
const int N=1e3+10;
int n,k,a[M],f[M][110];
int kq=0;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "1"
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin >> n >> k;
fori(i,1,n) cin >> a[i];
memset(f,61,sizeof(f));
f[0][0]=0;
fori(j,1,k)
{
fori(i,1,n)
{
int ma=0;
for(int pos=i;pos!=0;pos--)
{
ma=max(ma,a[pos]);
f[i][j]=min(f[i][j],f[pos-1][j-1]+ma);
}
}
}
cout << f[n][k] ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |