-
Notifications
You must be signed in to change notification settings - Fork 6
/
Scores.cpp
47 lines (31 loc) · 905 Bytes
/
Scores.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
vector<int> Solution::solve(vector<int> &A, vector<int> &B) {
int n = A.size(),m=B.size();
vector<pair<int,int> > v;
v.push_back({INT_MIN,2});
for(int i=0;i<n;i++){
v.push_back({A[i],0});
}
for(int i=0;i<m;i++){
v.push_back({B[i],1});
}
sort(v.begin(),v.end());
int diff = INT_MIN,fir,sec;
int cnt1=0,cnt2=0;
for(int i=v.size()-1;i>=0;i--){
pair<int,int> p =v[i];
int tot = 3*cnt1 + (2*(n-cnt1)) - (3*cnt2 + (2*(m-cnt2)));
if(tot>diff){
fir = 3*cnt1 + (2*(n-cnt1));
sec = (3*cnt2 + (2*(m-cnt2)));
diff =tot;
}
if(p.second ==0){
cnt1++;
}else{
cnt2++;
}
}
vector<int> v1;
v1.push_back(fir);v1.push_back(sec);
return v1;
}