https://codeforces.com/contest/1471/problem/A
题意:对于数组b可以两两合并其中的相连元素,beauty值就是对于数组b中的b[i]除以k向上取整的和,求出beauty值的范围。
题目挺好理解,就是要注意是向上取整。(我用翻译软件就是四舍五入呜呜呜),观察后发现对于任意两个相连元素a和b,合并后的beauty值是肯定<=不合并的beauty值的,因为如果a,b都不能整除k最后的结果就是向上+2(a/k+1和b/k+1)而合并之后的a+b除以k的值最大也只能向上+1。这样就可以知道不做操作就是取到最大值,全部合并就是取到最小值。
#include <bits/stdc++.h>
using namespace std;
#define qc std::ios::sync_with_stdio(0);
int a[100001];
int ans[100001];
int main() {
qc;
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
int x;
long long sum = 0;
long long max = 0, min = 0;
cin >> n >> x;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] % x == 0)
ans[i] = a[i] / x;
else
ans[i] = a[i] / x + 1;
sum += a[i];
max += ans[i];
}
if (sum % x == 0)
min = sum / x;
else
min = sum / x + 1;
cout << min << " " << max << endl;
}
}