답안 #684350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684350 2023-01-21T01:16:52 Z coldy Rasvjeta (COCI17_rasvjeta) C++14
50 / 50
1 ms 212 KB
#include <iostream>
#include <set>
using namespace std;
int main(){
    int n, m, k;
    cin>>n>>m>>k;
    bool lit[n + 1];
    for(int i = 1; i <= n; i++)lit[i] = 0;
    set <int> unlit;
    for(int i = 0; i < m; i++){
        int pos; cin>>pos;
        int start = max(pos - k, 1), end = min(pos + k, n);
        //cout<<start<<" "<<end<<endl;
        for(; start <= end; start++)lit[start] = 1;
    }
    // for(int i = 1; i <= n; i++){
    //     cout<<lit[i]<<" ";
    // }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!lit[i]){ 
            ans++;
            int pos = min(i + k, n);
            int l = pos - 1, r = pos + 1;
            lit[pos] = 1;
            for(; l >= pos - k && l >= 1; l--)lit[l] = 1;
            for(; r <= n && r <= pos + k; r++)lit[r] = 1;
        }
    }cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct