Submission #1056691

# Submission time Handle Problem Language Result Execution time Memory
1056691 2024-08-13T10:38:14 Z DorostWef Radio Towers (IOI22_towers) C++17
0 / 100
9 ms 2136 KB
#include "towers.h"

#include <bits/stdc++.h>

using namespace std;

const int N = 2002;
int h[N];
bool f[N];
int n;

void init(int N, std::vector<int> H) {
	n = N;
	for (int i = 0; i < n; i++)
		h[i] = H[i];
}

int solve (int l, int r, int d) {
	if (l > r)
		return 0;
	if (l == r)
		return f[l];
	int mx = -1, in = -1;
	for (int i = l; i <= r; i++) {
		if (h[i] > mx) {
			mx = h[i];
			in = i;
		}
	}
	int fin = (int)f[in];
	//if (f[in]) {
		for (int i = l; i <= r; i++) {
			if (h[i] > mx - d)
				f[i] = false;
		}
	//}
	return max (fin, solve (l, in - 1, d) + solve(in + 1, r, d));
}

int max_towers(int L, int R, int D) {
	for (int i = 0; i < N; i++)
		f[i] = true;
	return max (1, solve (L, R, D));
}
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1368 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '292', found: '271'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '292', found: '271'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 2136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '292', found: '271'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1368 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -