# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
5734 |
2014-05-15T02:29:18 Z |
kriii |
K blocks (IZhO14_blocks) |
C++ |
|
40 ms |
2408 KB |
#include <stdio.h>
#include <stack>
using namespace std;
int N,K,A[100001],prv[100001],nxt[100001];
int main()
{
scanf ("%d %d",&N,&K);
for (int i=1;i<=N;i++){
scanf ("%d",&A[i]);
prv[i] = 0x3fffffff;
}
for (int j=1;j<=K;j++){
stack<pair<int, int> > S;
for (int i=j;i<=N;i++){
int last = prv[i-1];
while (!S.empty() && S.top().second <= A[i]){
last = S.top().first;
S.pop();
}
if (S.empty() || S.top().first + S.top().second > last + A[i])
S.push(make_pair(last,A[i]));
nxt[i] = S.top().first + S.top().second;
}
for (int i=j;i<=N;i++) prv[i] = nxt[i];
}
printf ("%d\n",prv[N]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2408 KB |
Output is correct |
2 |
Correct |
0 ms |
2408 KB |
Output is correct |
3 |
Correct |
0 ms |
2408 KB |
Output is correct |
4 |
Correct |
0 ms |
2408 KB |
Output is correct |
5 |
Correct |
0 ms |
2408 KB |
Output is correct |
6 |
Correct |
0 ms |
2408 KB |
Output is correct |
7 |
Correct |
0 ms |
2408 KB |
Output is correct |
8 |
Correct |
0 ms |
2408 KB |
Output is correct |
9 |
Correct |
0 ms |
2408 KB |
Output is correct |
10 |
Correct |
0 ms |
2408 KB |
Output is correct |
11 |
Incorrect |
0 ms |
2408 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2408 KB |
Output is correct |
2 |
Correct |
0 ms |
2408 KB |
Output is correct |
3 |
Correct |
0 ms |
2408 KB |
Output is correct |
4 |
Correct |
0 ms |
2408 KB |
Output is correct |
5 |
Correct |
0 ms |
2408 KB |
Output is correct |
6 |
Correct |
0 ms |
2408 KB |
Output is correct |
7 |
Correct |
0 ms |
2408 KB |
Output is correct |
8 |
Correct |
0 ms |
2408 KB |
Output is correct |
9 |
Correct |
0 ms |
2408 KB |
Output is correct |
10 |
Correct |
0 ms |
2408 KB |
Output is correct |
11 |
Incorrect |
0 ms |
2408 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2408 KB |
Output is correct |
2 |
Correct |
4 ms |
2408 KB |
Output is correct |
3 |
Correct |
8 ms |
2408 KB |
Output is correct |
4 |
Incorrect |
40 ms |
2408 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |