-
Notifications
You must be signed in to change notification settings - Fork 23
/
dice.cpp
40 lines (35 loc) · 786 Bytes
/
dice.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
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
pair<int, int> dice(vector<int> att, vector<int> def) {
int L, R, size;
L = R = 0;
size = min(att.size(), def.size());
sort(att.rbegin(), att.rend());
sort(def.rbegin(), def.rend());
for (int i = 0; i < size; i++)
(att[i] <= def[i]) ? L++ : R++;
return {L, R};
}
int main() {
freopen("dice.in", "r", stdin);
freopen("output.out", "w", stdout);
int T, k = 1;
cin >> T;
while (T--) {
int A, D;
pair<int, int> res;
cin >> A >> D;
vector<int> att(A), def(D);
for (int i = 0; i < A; i++)
cin >> att[i];
for (int i = 0; i < D; i++)
cin >> def[i];
res = dice(att, def);
cout << k << ". " << res.first << " " << res.second << endl;
k++;
}
return 0;
}