-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva410.cpp
More file actions
48 lines (35 loc) · 855 Bytes
/
Copy pathuva410.cpp
File metadata and controls
48 lines (35 loc) · 855 Bytes
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
/*
* Contest : UVA
* Problem : 410 - Station Balance
* Link : https://vjudge.net/problem/UVA-410
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
int c, s, set = 1, x;
while (cin >> c >> s) {
int n = 2 * c;
int v[n] = {0};
double avg = 0, imbalance = 0;
for (int i = 0; i < s; i++) {
cin >> v[i];
avg += v[i];
}
avg /= c;
sort(v, v + n);
printf("Set #%i\n", set++);
for (int i = 0; i < c; i++) {
int chamber = v[i] + v[n - 1 - i];
cout << " " << i << ":";
if (v[i]) cout << " " << v[i];
if (v[n - 1 - i]) cout << " " << v[n - 1 - i];
cout << "\n";
imbalance += abs(chamber - avg);
}
printf("IMBALANCE = %.5f\n\n", imbalance);
}
return 0;
}