Submission #5737

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
57372014-05-15 02:33:54kriiiK blocks (IZhO14_blocks)C++98
Compilation error
0 ms0 KiB
#include <stdio.h>
int N,K,A[100001],prv[100001],nxt[100001];
int P[100001],Q[100001],sz;
int main()
{
scanf ("%d %d",&N,&K);
for (int i=1;i<=N;i++){
scanf ("%d",&A[i]);
prv[i] = 0x3fffffff;
}
while (K--){
P[0] = 0; Q[0] = 0x3fffffff; sz = 0;
nxt[0] = 0x3fffffff;
for (int i=1;i<=N;i++){
int last = prv[i-1];
while (Q[sz] <= A[i]){
if (last > P[sz]) last = P[sz];
sz--;
}
if (P[sz] + Q[sz] > last + A[i]){
sz++; P[sz] = last; Q[sz] = A[i];
}
nxt[i] = P[sz] + Q[sz];
}
for (int i=0;i<=N;i++) prv[i] = nxt[i];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

blocks.cpp:36:2: error: 'x' does not name a type
blocks.cpp: In function 'int main()':
blocks.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
blocks.cpp:11:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]