-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Strange_Partition.cpp
73 lines (66 loc) · 1.42 KB
/
A_Strange_Partition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 // 1e9+7
#define ll long long int
#define read(arr, n) \
for (ll i = 0; i < n; i++) \
cin >> arr[i];
#define print(arr, n) \
for (ll i = 0; i < n; i++) \
cout << arr[i] << ' '; \
cout << endl;
#define fori(s, e, g) for (ll i = s; i <= e; i += g)
#define ford(s, e, g) for (ll i = s; i >= e; i -= g)
#define p(temp) cout << temp << endl
ll sum(ll arr[], ll n)
{
ll s = 0;
for (ll i = 0; i < n; i++)
s += arr[i];
return s;
}
ll maxi(ll arr[], ll n)
{
ll m = -1e18;
for (ll i = 0; i < n; i++)
m = max(m, arr[i]);
return m;
}
ll mini(ll arr[], ll n)
{
ll m = 1e18;
for (ll i = 0; i < n; i++)
m = min(m, arr[i]);
return m;
}
bool getParity(ll a, ll b) { return ((a ^ b) & 1); } // true for same, false for different
void print_vect(vector<ll> &vect)
{
for (auto it : vect)
cout << it << ' ';
cout << endl;
}
// space for helper functions
void solve()
{
ll n, x;
cin >> n >> x;
ll arr[n];
read(arr, n);
ll summ = sum(arr, n);
ll maxRes = summ % x == 0 ? summ / x : summ / x + 1;
ll minRes = 0;
fori(0, n - 1, 1)
{
minRes += arr[i] % x == 0 ? arr[i] / x : arr[i] / x + 1;
}
cout << maxRes << " " << minRes << endl;
}
int main()
{
ll tc;
cin >> tc;
while (tc--)
solve();
return 0;
}