Submission #171933

# Submission time Handle Problem Language Result Execution time Memory
171933 2019-12-30T16:27:12 Z ToniB Rasvjeta (COCI17_rasvjeta) C++14
45 / 50
2 ms 380 KB
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    
    int ulica[n] = {0};
    
    for(int i = 0; i < m; ++i){
    	int s;
    	cin >> s;
    	s -= 1;
    	
    	for(int j = (s - k); j <= (s + k); ++j){
    		
    		if(j >= 0 and j < n) ulica[j] = 1;
		}
	}
	
	int coord1 = 0, coord2 = 0;
	int len = 0, sol = 0;
	
	for(int i = 0; i < n; ++i){
	    if(ulica[i] == 0 and coord1 == 0){
	    	coord1 = i;
	    	len = 1;
		}
		else if(ulica[i] == 0 and coord1 != 0){
			len += 1;
		}
		else if(ulica[i] == 1 and coord1 != 0){
			coord2 = i;
			int uk = 0;
			
			uk = len / (2 * k + 1);
			
			if(len % (2 * k + 1) != 0) uk++;
			
			sol += uk;
			coord2 = coord1 + (uk * (2 * k + 1));
			
			for(int j = coord1; j <= coord2; ++j){
				ulica[j] = 1;
			}
			
			coord1 = 0;
			coord2 = 0;
			len = 0;
			
		}
	}
	
	if(len != 0){
		sol += (len / (2 * k + 1));
		
		if(len % (2 * k + 1) != 0) sol++;
	}
	
	cout << sol;
    
    

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 380 KB Output isn't correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct