Submission #475368

# Submission time Handle Problem Language Result Execution time Memory
475368 2021-09-22T08:28:11 Z HossamHero7 Rasvjeta (COCI17_rasvjeta) C++14
50 / 50
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    int n,m,k;
    cin>>n>>m>>k;
    vector <bool> vis(n+1);
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        for(int i=x;i>=max(x-k,1);i--){
            vis[i] = 1;
        }
        for(int i=x;i<=min(x+k,n);i++){
            vis[i] = 1;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            ans ++;
            int lamp = min(i + k,n);
            for(int j=lamp;j>=max(lamp-k,1);j--){
                vis[j] = 1;
            }
            for(int j=lamp;j<=min(lamp+k,n);j++){
                vis[j] = 1;
            }
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct