My issue
can anyone help me know what is wrong in this code ?
include
using namespace std;
int main() {
int t ;
cin >> t;
while (t–){
int n, k, sum = 0;
cin >> n >> k;
int i = 0;
int a[n];
while (n–){
cin >> a[i];
sum += a[i];
i ++;
}
if (sum < n ) cout << “nO” << endl;
else if (sum % n != 0 || k == 0){
cout << “NO” << endl;
}
else {
cout << “YES” << endl;
}
}
return 0;
}
My code
#include <iostream>
using namespace std;
int main() {
int t ;
cin >> t;
while (t--){
int n, k, sum = 0;
cin >> n >> k;
int i = 0;
int a[n];
while (n--){
cin >> a[i];
sum += a[i];
i ++;
}
if (sum < n ) cout << "nO" << endl;
else if (sum % n != 0 && k == 0){
cout << "NO" << endl;
}
else {
cout << "YES" << endl;
}
}
return 0;
}
Problem Link: SANTACHOC Problem - CodeChef