The question was
A semester in Chef's University has 120 working days. The University's requirement is that a student should be present for at least 75% of the working days in the semester. If not, the student is failed.
Chef has been taking a lot of holidays, and is now concerned whether he can pass the attendance requirement or not. N working days have already passed, and you are given N bits - B1, B2, ..., BN. Bi = 0 denotes that Chef was absent on the ith day, and Bi = 1 denotes that Chef was present on that day.
Can Chef hope to pass the requirement by the end of the semester?
Input:
First line will contain T, the number of testcases. Then the testcases follow. Each testcase contains two lines of input. The first line of each testcase contains a single integer, N, the number of days till now. The second line of each testcase contains a string BB of length N where Bi represents the status of the ith day.
Output:
For each testcase, output the answer in a single line - "YES" if Chef can pass the attendance requirement and "NO" if not.
And i came up with this code
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
int cnt = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 1) {
cnt++;
}
}
if (cnt >= n-30) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
I don't know what's wrong with this code.