#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];
}
}
}
void output(void)
{
printf("%d",D[K%2][N]);
}
int main(void)
{
input();
process();
output();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2260 KB |
Output is correct |
2 |
Correct |
0 ms |
2260 KB |
Output is correct |
3 |
Correct |
0 ms |
2260 KB |
Output is correct |
4 |
Correct |
0 ms |
2260 KB |
Output is correct |
5 |
Correct |
0 ms |
2260 KB |
Output is correct |
6 |
Correct |
0 ms |
2260 KB |
Output is correct |
7 |
Correct |
0 ms |
2260 KB |
Output is correct |
8 |
Incorrect |
0 ms |
2260 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2260 KB |
Output is correct |
2 |
Correct |
0 ms |
2260 KB |
Output is correct |
3 |
Correct |
0 ms |
2260 KB |
Output is correct |
4 |
Correct |
0 ms |
2260 KB |
Output is correct |
5 |
Correct |
0 ms |
2260 KB |
Output is correct |
6 |
Correct |
0 ms |
2260 KB |
Output is correct |
7 |
Correct |
0 ms |
2260 KB |
Output is correct |
8 |
Incorrect |
0 ms |
2260 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2260 KB |
Output is correct |
2 |
Correct |
8 ms |
2260 KB |
Output is correct |
3 |
Correct |
4 ms |
2260 KB |
Output is correct |
4 |
Incorrect |
24 ms |
2260 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |