Submission #8488496


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;

ll ans = 0;
vector<int> diff;
int n,k;
int v[305];

void f(int l, int r) {
	if(l > r) return ;
	int minn = 1e9;

	for(int i = l; i <= r; i++)
		minn = min(minn, v[i]);

	ans += minn;
	int last = l;
	for(int i = l; i <= r; i++) {
		v[i] -= minn;
	}

	for(int i = l; i <= r; i++) {
		if(v[i] == 0 && i > l && i < r && v[i-1] > 0 && v[i+1] > 0)
			diff.push_back(min(v[i-1], v[i+1]));
	}

	for(int i = l; i <= r; i++)
		if(v[i] == 0) {
			f(last, i-1);
			last = i;
		}
}

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

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

	f(0, n-1);



	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 795 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:42: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:45: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
WA × 3
AC × 1
WA × 22
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 WA 1 ms 256 KB
case_01.txt WA 1 ms 256 KB
case_02.txt WA 1 ms 256 KB
case_03.txt WA 1 ms 256 KB
case_04.txt WA 1 ms 256 KB
case_05.txt WA 1 ms 256 KB
case_06.txt WA 1 ms 256 KB
case_07.txt WA 1 ms 256 KB
case_08.txt WA 1 ms 256 KB
case_09.txt WA 1 ms 256 KB
case_10.txt WA 1 ms 256 KB
case_11.txt WA 1 ms 256 KB
case_12.txt WA 1 ms 256 KB
case_13.txt WA 1 ms 256 KB
case_14.txt WA 1 ms 256 KB
case_15.txt WA 1 ms 256 KB
case_16.txt WA 1 ms 256 KB
case_17.txt WA 1 ms 256 KB
case_18.txt WA 1 ms 256 KB
case_19.txt AC 1 ms 256 KB
case_20.txt WA 1 ms 256 KB