답안 #684304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684304 2023-01-20T20:30:45 Z Breadz Rasvjeta (COCI17_rasvjeta) C++17
50 / 50
1 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
bitset<2001> bs;
int main()
{
  int n; cin >> n;
  int m; cin >> m;
  int k; cin >> k;
  vector<int> lights(m);
  for(int i = 0; i < m; i++)
  {
    cin >> lights[i];
    for(int j = max(lights[i]-k, 1); j <= min(lights[i]+k, n); j++){bs[j] = 1;}
  }
  int ans = 0;
  for(int i = 1; i <= n; i++)
  {
    if(!bs[i])
    {
      ans++;
      int val = i+k;
      for(int j = max(val-k, 1); j <= min(val+k, n); j++){bs[j] = 1;}
    }
  }
  cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct