Submission #7128

# Submission time Handle Problem Language Result Execution time Memory
7128 2014-07-26T10:53:56 Z baneling100 K blocks (IZhO14_blocks) C++
0 / 100
4 ms 2260 KB
#include <stdio.h>

int N, K, A[100001], D[2][100001];

void input(void)
{
    int i;

    scanf("%d %d",&N,&K);
    for(i=1 ; i<=N ; i++)
        scanf("%d",&A[i]);
}

void process(void)
{
    int i, j, Max;

    for(i=1 ; i<=K ; i++)
    {
        Max=A[i];
        D[i%2][i]=D[1-(i%2)][i-1]+A[i];
        for(j=i+1 ; j<=N ; j++)
        {
            if(Max<A[j])
            {
                D[i%2][j]=D[i%2][j-1]+A[j]-Max;
                Max=A[j];
            }
            else
                D[i%2][j]=D[i%2][j-1];
            if(D[i%2][j]=D[1-(i%2)][j-1]+A[j])
                D[i%2][j]>D[1-(i%2)][j-1]+A[j];
        }
    }
}

void output(void)
{
    printf("%d",D[K%2][N]);
}

int main(void)
{
    input();
    process();
    output();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2260 KB Output is correct
2 Incorrect 0 ms 2260 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2260 KB Output is correct
2 Incorrect 0 ms 2260 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -