Submission #40399

#TimeUsernameProblemLanguageResultExecution timeMemory
40399szawinisRasvjeta (COCI17_rasvjeta)C++14
50 / 50
2 ms756 KiB
#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 timeMemoryGrader output
Fetching results...