Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool illuminati[1000];
  5.  
  6. int main()
  7. {
  8.     ios_base::sync_with_stdio(false);
  9.     cin.tie(NULL);
  10.     int n,m,k,cont=0,tot=0;
  11.     cin>>n>>m>>k;
  12.     int lampioni[m];
  13.     for(int i = 0 ; i < m ; i++ )
  14.     {
  15.         cin>>lampioni[i];
  16.     }
  17.     for(int i = 0 ; i < m ; i++ )
  18.     {
  19.         for(int j = (lampioni[i]-1)+k ; j>=(lampioni[i]-1)-k; j--){
  20.             if(j==0){
  21.                 illuminati[j]=true;
  22.                 break;
  23.             }else{
  24.                 illuminati[j]=true;
  25.             }
  26.         }
  27.     }
  28.     k=k*2+1;
  29.     int i=0;
  30.     while(i<n){
  31.         cont=0;
  32.         while(illuminati[i]==false&&i<n){
  33.             cont++;
  34.             i++;
  35.         }
  36.         if(cont>0){
  37.             if(cont%k==0){
  38.                 tot+=cont/k;
  39.             }else{
  40.                 tot+=((cont/k)+1);
  41.             }  
  42.         }
  43.         while(illuminati[i]==true&&i<n){
  44.             i++;
  45.         }
  46.     }
  47.     cout<<tot;                 
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement