Submission #8490797


Source Code Expand

Copy
#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int n,k;
int v[305];
ll dp[305][305];

int main() {
	scanf("%d%d", &n, &k);

	for(int i = 1; i <= n; i++)
		scanf("%d", &v[i]);

	for(int i = 1; i <= n+1; i++) {
		for(int j = 0; j <= min(k,i); j++) {
			dp[i][j] = 1e18;
			for(int l = 0; l <= j; l++) {
				dp[i][j] = min(dp[i][j], dp[i-l-1][j-l] + max(0, v[i] - v[i-l-1])); 
			}
		}
	}

	ll ans = 1e18;
	for(int i = 0; i <= k; i++)
		ans = min(ans, dp[n+1][i]);

	printf("%lld\n", ans);

    return 0;
}

Submission Info

Submission Time
Task F - Laminate
User pedrohlf
Language C++14 (GCC 5.4.1)
Score 0
Code Size 620 Byte
Status WA
Exec Time 15 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
                       ^
./Main.cpp:19:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 1
WA × 2
AC × 3
WA × 20
Set Name Test Cases
Sample Sample_01.txt, Sample_02.txt, Sample_03.txt
All Sample_01.txt, Sample_02.txt, Sample_03.txt, case_01.txt, case_02.txt, case_03.txt, case_04.txt, case_05.txt, case_06.txt, case_07.txt, case_08.txt, case_09.txt, case_10.txt, case_11.txt, case_12.txt, case_13.txt, case_14.txt, case_15.txt, case_16.txt, case_17.txt, case_18.txt, case_19.txt, case_20.txt
Case Name Status Exec Time Memory
Sample_01.txt WA 1 ms 256 KB
Sample_02.txt WA 1 ms 256 KB
Sample_03.txt AC 1 ms 256 KB
case_01.txt WA 9 ms 1024 KB
case_02.txt WA 9 ms 1024 KB
case_03.txt WA 10 ms 1024 KB
case_04.txt WA 10 ms 1024 KB
case_05.txt WA 11 ms 1024 KB
case_06.txt WA 12 ms 1024 KB
case_07.txt WA 12 ms 1024 KB
case_08.txt WA 13 ms 1024 KB
case_09.txt WA 13 ms 1024 KB
case_10.txt WA 14 ms 1024 KB
case_11.txt AC 1 ms 1024 KB
case_12.txt AC 1 ms 1024 KB
case_13.txt WA 15 ms 1024 KB
case_14.txt WA 15 ms 1024 KB
case_15.txt WA 8 ms 1024 KB
case_16.txt WA 7 ms 1024 KB
case_17.txt WA 8 ms 1024 KB
case_18.txt WA 8 ms 1024 KB
case_19.txt WA 8 ms 1024 KB
case_20.txt WA 8 ms 1024 KB