My issue
in vs code my answer is correct but in codechef compiler its giving wrong solution
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, swipes;
cin >> n >> swipes;
bool arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int flag = 1;
int swipe = 0;
for (int i = 0; i < n; i++) {
if (arr[i]) {
swipe = swipes;
} else {
swipe = swipe - 1;
if (swipe < 0) {
flag = 0;
}
}
if (flag == 0) {
break;
}
}
if (flag == 1) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
Problem Link: Access Control Practice Coding Problem - CodeChef