My issue
on which test case does my code fails
My code
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main() {
int t;
cin >> t;
while (t--)
{
int n, k;
cin >> n >> k;
int a[n];
long long sum = 0;
int counter = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i];
if (a[i] % k == 0)
{
sum += (a[i] / k);
}
else {
sum += ((a[i] + k - 1) / k);
counter++;
}
}
if (sum <= counter && sum >= 0)
{
cout << "YES" << endl;
}
else cout << "NO" << endl;
}
return 0;
}
Problem Link: Nice Array Practice Coding Problem