forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaverageshard.cpp
More file actions
49 lines (36 loc) · 1.09 KB
/
averageshard.cpp
File metadata and controls
49 lines (36 loc) · 1.09 KB
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
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i++) {
int comp, econ;
cin >> comp >> econ;
vector<int> comp_iq, econ_iq;
long double comp_total = 0, econ_total = 0;
for(int j = 0; j < comp; j++) {
int temp;
cin >> temp;
comp_iq.push_back(temp);
comp_total += temp;
}
for(int j = 0; j < econ; j++) {
int temp;
cin >> temp;
econ_iq.push_back(temp);
econ_total += temp;
}
long double comp_avg_old = comp_total / comp;
long double econ_avg_old = econ_total / econ;
int funny = 0;
for(int j = 0; j < comp; j++) {
long double comp_avg_new = (comp_total - comp_iq[j]) / (comp - 1);
long double econ_avg_new = (econ_total + comp_iq[j]) / (econ + 1);
if(comp_avg_new > comp_avg_old && econ_avg_new > econ_avg_old) {
funny++;
}
}
cout << funny << endl;
}
}