-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1914D.cpp
More file actions
56 lines (49 loc) · 1.31 KB
/
1914D.cpp
File metadata and controls
56 lines (49 loc) · 1.31 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
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<pair<int, int>> a(n), b(n), c(n);
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
a[i] = {temp, i};
}
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
b[i] = {temp, i};
}
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
c[i] = {temp, i};
}
sort(a.begin(), a.end(), greater<>());
sort(b.begin(), b.end(), greater<>());
sort(c.begin(), c.end(), greater<>());
int maxi = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
int idx1 = a[i].second;
int idx2 = b[j].second;
int idx3 = c[k].second;
if (idx1 != idx2 && idx2 != idx3 && idx1 != idx3) {
int sum = a[i].first + b[j].first + c[k].first;
maxi = max(maxi, sum);
}
}
}
}
cout << maxi << '\n';
}
return 0;
}