My issue
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n,k,v;
cin>>n>>k>>v;
int arr[n];
int sum=0;
for(int i=0;i<n;i++)
{
cin>>arr[i];
sum+=arr[i];
}
int x=v*(n+k)-sum;
if(x%k==0 && x>0)cout<<x/3<<endl;
else cout<<-1<<endl;
}
}
I am not able to debug mistake.help…
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n,k,v;
cin>>n>>k>>v;
int arr[n];
int sum=0;
for(int i=0;i<n;i++)
{
cin>>arr[i];
sum+=arr[i];
}
int x=v*(n+k)-sum;
if( x%k==0 && x>0 )cout<<x/3<<endl;
else cout<<-1<<endl;
}
}
Problem Link: Average Number Practice Coding Problem - CodeChef