| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 93982 | kjain_1810 | K blocks (IZhO14_blocks) | C++17 | 18 ms | 452 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 pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
using namespace std;
const int N=105;
const int MOD=1e9+7;
typedef long long ll;
typedef long double ld;
ll n, k, arr[N], dp[N][N];
ll solve(ll i, ll j)
{
if(j==0)
if(i==n+1)
return 0;
else
return 1e15;
if(i==n+1)
return 1e15;
if(dp[i][j]!=-1)
return dp[i][j];
ll ret=1e15;
ll maxi=0;
for(ll b=i; b<=n; b++)
{
maxi=max(maxi, arr[b]);
ret=min(ret, solve(b+1, j-1)+maxi);
}
return dp[i][j]=ret;
}
int main()
{
inlld2(n, k);
for(ll a=1; a<=n; a++)
inlld(arr[a]);
memset(dp, -1, sizeof(dp));
printf("%lld\n", solve(1, k));
return 0;
}
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... | ||||
