Submission #40399

# Submission time Handle Problem Language Result Execution time Memory
40399 2018-01-31T13:17:57 Z szawinis Rasvjeta (COCI17_rasvjeta) C++14
50 / 50
2 ms 756 KB
#include <bits/stdc++.h>
using namespace std;

int n, m, k, ans;
bool mark[1001];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> k;
	for(int i = 0, x; i < m; i++) {
		cin >> x;
		for(int j = max(x-k, 1); j <= min(x+k, n); j++) mark[j] = true;
	}
	int last = 0;
	mark[0] = true;
	for(int i = 1; i <= n; i++) {
		if(!mark[i] && mark[i-1]) last = i;
		else if(mark[i] && !mark[i-1]) ans += (i-last+2*k) / (2*k+1);
	}
	if(!mark[n]) ans += (n+1-last+2*k) / (2*k+1);
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 420 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 756 KB Output is correct
10 Correct 2 ms 756 KB Output is correct