답안 #98099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98099 2019-02-20T16:50:13 Z dalgerok Rasvjeta (COCI17_rasvjeta) C++17
50 / 50
3 ms 384 KB
#include<bits/stdc++.h>
using namespace std;




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int a[n + 5];
    memset(a, 0, sizeof(a));
    for(int i = 1; i <= m; i++){
        int x;
        cin >> x;
        a[max(1, x - k)] += 1;
        a[min(n + 1, x + k + 1)] -= 1;
    }
    int cur = 0, ans = 0;
    for(int i = 1; i <= n; i++){
        cur += a[i];
        if(cur == 0){
            ans += 1;
            cur += 1;
            a[min(n + 1, i + 2 * k + 1)] -= 1;
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct