# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475368 | HossamHero7 | Rasvjeta (COCI17_rasvjeta) | C++14 | 1 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |