Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int x, s, n;
- cin >> x >> s >> n;
- int *ar = new int[x];
- for (int i = 0; i < x; i++)
- ar[i] = 0;
- int bread;
- for (int i = 0; i < n; i++){
- cin >> bread;
- ar[bread - 1] = -1;
- }
- // START:
- // {
- for (int i = x - 2; i >= 0; i--){
- if (ar[i] == -1)
- continue;
- int min = -1;
- int lim = (i + s) > (x - 1) ? x - 1 : i + s;
- for (int j = i + 1; j <= lim; j++){
- if (ar[j] != -1)
- if (ar[j] < min || min == -1)
- min = ar[j];
- }
- if (min == -1){
- cout << "YES" << endl;
- return 0;
- }
- ar[i] = min + 1;
- }
- // for (int i = 0; i < x; i++){
- // cout << ar[i] << " ";
- // }
- // cout << endl;
- // }
- for (int i = 1; i < x - 1; i++){
- int lim = (i + s) > (x - 1) ? x - 1 : i + s;
- int min_count = 1, count = 0, min = -1;
- bool dif = false;
- // cout << "lim : " << lim << endl;
- for (int j = i; j < lim - 1; j++){
- if (ar[j] < 0){
- if (ar[j + 1] > 0 && (min == -1 || ar[j + 1] < min))
- min = ar[j + 1];
- // cout << j + 1 << " " << min << endl;
- continue;
- }
- if (ar[j + 1] > 0){
- if (ar[j] != ar[j + 1]){
- dif = true;
- count = min_count;
- min_count = 0;
- }
- min = ar[j + 1];
- // cout << j + 1 << " " << min << endl;
- }
- min_count++;
- }
- if ((min_count < min && (count + min_count - 1) < min)){
- cout << "YES" << endl;
- // cout << min << endl;
- // cout << count << " " << min_count << endl << dif << endl;
- return 0;
- }
- }
- // int tmp;
- // do{
- // cin >> tmp;
- // if (tmp > 0){
- // ar[tmp - 1] = -1;
- // goto START;
- // }
- // }while(tmp > 0);
- cout << "NO" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement