# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547310 | 2022-04-10T10:30:45 Z | krit3379 | K blocks (IZhO14_blocks) | C++17 | 1 ms | 340 KB |
#include<bits/stdc++.h> using namespace std; #define N 100005 int a[N],l[N],dp[105][N]; int main(){ int n,k,i,j; scanf("%d %d",&n,&k); a[0]=2e9; for(i=1;i<=n;i++){ scanf("%d",&a[i]); l[i]=i-1; while(a[i]>a[l[i]])l[i]=l[l[i]]; } for(i=0;i<=k;i++)for(j=0;j<=n;j++)dp[i][j]=1e9; for(i=1;i<=n;i++){ if(l[i]==0)dp[1][i]=a[i]; dp[1][i]=min(dp[1][i],dp[1][l[i]]); } for(i=2;i<=k;i++){ for(j=i;j<=n;j++){ dp[i][j]=min({dp[i][j],dp[i][l[j]],dp[i-1][l[j]+1]+a[j],dp[i-1][j-1]+a[j]}); } } printf("%d",dp[k][n]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 224 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Incorrect | 0 ms | 340 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 304 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 304 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Incorrect | 1 ms | 308 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 224 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Incorrect | 0 ms | 340 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 224 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Incorrect | 0 ms | 340 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |