Submission #475368

#TimeUsernameProblemLanguageResultExecution timeMemory
475368HossamHero7Rasvjeta (COCI17_rasvjeta)C++14
50 / 50
1 ms204 KiB
#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 timeMemoryGrader output
Fetching results...