Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int q, n, sum;
int main() {
#ifndef ONLINE_JUDGE
freopen("in", "r", stdin);
#endif
scanf("%d", &q);
for(int i = 0; i < q; ++i) {
sum = 0;
scanf("%d", &n);
for(int j = 0, tmp; j < n; ++j)
scanf("%d", &tmp), sum += tmp;
printf("%d\n", (sum + (n - 1)) / n);
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
3
5
1 2 3 4 5
3
1 2 2
4
1 1 1 1
5
1 2 3 4 5
3
1 2 2
4
1 1 1 1
Output
3
2
1
2
1
Demonstration
Codeforcess Solution A. Equalize Prices Again-Solution in C, C++, Java, Python ,Codeforcess Solution