Submission #165618

# Submission time Handle Problem Language Result Execution time Memory
165618 2019-11-27T19:35:11 Z itiam Rasvjeta (COCI17_rasvjeta) C++11
50 / 50
2 ms 376 KB
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int L[1003];
int main(){
    int N,M,K,P,z,z2,br=0;
    cin >> N >> M >> K;
    //K+=1;
    for (int i=0;i<M;i++){
        cin >> P;
        P-=1;
        z=P-K;
        z2=P+K+1;
        if (z<0)    z=0;
        if (z2>N)   z2=N;
        for (int j=z;j<z2;j++){
            L[j]=1;
        }
    }
    //for(int i=0; i<N;i++)    cout << L[i] << " ";
    //cout << "\n";
    for (int i=0;i<N;i++){
        if (L[i]==0){
            P=i+K;
            z=P-K;
            z2=P+K+1;
            if (z<0)    z=0;
            if (z2>N)   z2=N;
            for (int j=z;j<z2;j++){
                L[j]=1;
            }
            br+=1;
            /*cout << br << ":    ";
            for(int i=0; i<N;i++)    cout << L[i] << " ";
            cout << "\n";*/
        }
    }
    //for(int i=0; i<N;i++)    cout << L[i] << " ";
    //cout << "\n";
    cout << br;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct