Answer the question
In order to leave comments, you need to log in
How to overcome overflow?
I decide
#include <bits/stdc++.h>
using namespace std;
long long div_up(int x, int y)
{
return (x - 1) / y + 1;
}
int main()
{
int t;
cin>>t;
while(t--){
long long n,x;
cin>>n>>x;
vector<int> a(n);
for(int i=0;i<n;i++)
cin>>a[i];
long long sum = 0;
for(int i=0;i<n;i++)
sum = sum + a[i];
long long sum2 = 0;
for(int i=0;i<n;i++)
sum2 = sum2 + div_up(a[i],x);
long long mn = div_up(sum,x),mx = sum2;
cout<<mn<<" "<<mx<<endl;
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question