fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t; cin >> t;
  7. while(t-->0) {
  8. int n,x; cin >> n >> x;
  9. vector<int> a(n);
  10. int max_n=0; int sum=0;
  11. for(int i=0;i<n;++i) {
  12. cin >> a[i];
  13. max_n=max(max_n,a[i]);
  14. sum+=a[i];
  15. }
  16. int result=max(max_n,(sum+x-1)/x);
  17. cout << result << "\n";
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
3 2
3 1 2
3 3
2 1 3
5 3
2 2 1 9 2
7 4
2 5 3 3 5 2 5
stdout
3
3
9
7