# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104133 | Kewo | Rasvjeta (COCI17_rasvjeta) | C++17 | 2 ms | 384 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>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;
const int N = (int)(1e6 + 5);
const int LOG = (int)(20);
int n, m, k, ar[N], mark[N], pre[N], dp[N], ans;
int main() {
fast_io();
// freopen("inp.in", "r", stdin);
cin >> n >> m >> k;
for(int i = 1; i <= m; i++)
cin >> ar[i];
for(int i = 1; i <= m; i++) {
for(int j = ar[i]; j <= ar[i] + k && j <= n; j++)
mark[j] = 1;
for(int j = max(1, ar[i] - k); j <= ar[i]; j++)
mark[j] = 1;
}
int ls = -1;
for(int i = 1; i <= n; i++) {
if(ls == -1 && mark[i] == 0)
ls = i;
if(ls != -1 && (i - ls == k || i == n)) {
for(int j = i; j <= i + k && j <= n; j++)
mark[j] = 1;
for(int j = max(1, i - k); j <= i; j++)
mark[j] = 1;
ls = -1;
ans++;
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |