hello everyone, while solving this question , I took an array arr[n] of int because the numbers lie in range of 10^-5 and 10^5…I think the numbers can easily fit in int…but it gives me WA … but when i change it to long long int , it gives me AC…why so??
My submission : Submission #19424524 - AtCoder Beginner Contest 180
Problem Link : B - Various distances
Code :
void solve()
{
long long int n;
cin>>n;
**int arr[n];**// when i change it to long long int, it gives me AC, but why? since the constraints are not big, it should have worked fine with int also
for(lli i=0;i<n;i++)
cin>>arr[i];
long long int m=0;
long long int e=0;
int c=0;
for(lli i=0;i<n;i++)
{ m+=abs(arr[i]);
e+=arr[i]*arr[i];
c=max(c,abs(arr[i]));
}
double E=(double)(pow(e,0.5));
cout<<m<<endl;
cout<<E<<endl;
cout<<c<<endl;
}