Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n, k, w, dw, s;
- cin >> n >> k >> w >> dw >> s;
- vector<int> c(n + 1, 0);
- for (int idw = 1; idw <= dw; ++idw)
- {
- int wek;
- cin >> wek;
- for (int i = (wek+1 >= s) ? wek+1 - s : w - s + wek+1; i < n; i += w)
- {
- c[i] = -1;
- }
- }
- int dm;
- cin >> dm;
- for (int j = 1; j <= dm; ++j)
- {
- int m;
- cin >> m;
- c[m] = -1;
- }
- int len = 1;
- for (int i = 1; i <= n; ++i)
- {
- if (c[i] != -1)
- {
- if (len >= k)
- {
- c[i] = c[i - 1] + 1;
- }
- else
- {
- c[i] = (c[i-1] != -1)? c[i-1] : 0;
- }
- len++;
- }
- else
- {
- c[i] = c[i-1];
- len = 1;
- }
- }
- cout << c[n];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment