#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a,b) for (int a = 0; a < (b); ++a)
#define pb push_back
#define all(t) t.begin(), t.end()
struct Element
{
int val, idx;
bool operator < (const Element &element) const
{
return val < element.val;
}
};
const int MAXN = 1e5+4e5+50;
int n = 0, wyn = -1;
int A[MAXN];
int B[MAXN];
int C[MAXN];
bool czy_usunelismy[MAXN];
vector<Element> V1;
vector<Element> V2;
vector<Element> V3;
vector<int> spr;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
rep(i,n) cin >> A[i] >> B[i] >> C[i];
V1.assign(n,{}), V2.assign(n,{}), V3.assign(n,{});
rep(i,n) V1[i] = {A[i],i}, V2[i] = {B[i],i}, V3[i] = {C[i],i};
sort(all(V1)), sort(all(V2)), sort(all(V3));
while(V1.size() > 0 and V2.size() > 0 and V3.size() > 0)
{
spr = vector<int>();
spr.pb(V1.back().idx), spr.pb(V2.back().idx), spr.pb(V3.back().idx);
for (auto x : spr)
{
int cnt = 0;
if (V1.back().val == A[x]) ++cnt;
if (V2.back().val == B[x]) ++cnt;
if (V3.back().val == C[x]) ++cnt;
if (cnt > 1) czy_usunelismy[x] = true;
}
bool czy_OK = true;
if (czy_usunelismy[V1.back().idx] == true)
{
V1.pop_back(), czy_OK = false;
}
if (czy_usunelismy[V2.back().idx] == true)
{
V2.pop_back(), czy_OK = false;
}
if (czy_usunelismy[V3.back().idx] == true)
{
V3.pop_back(), czy_OK = false;
}
if (czy_OK)
{
wyn = V1.back().val + V2.back().val + V3.back().val;
break;
}
}
cout << wyn << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
728 KB |
Output is correct |
27 |
Correct |
2 ms |
604 KB |
Output is correct |
28 |
Correct |
2 ms |
740 KB |
Output is correct |
29 |
Correct |
2 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1 ms |
604 KB |
Output is correct |
32 |
Correct |
2 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
2 ms |
604 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
1 ms |
552 KB |
Output is correct |
39 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
26 ms |
6492 KB |
Output is correct |
12 |
Correct |
27 ms |
4704 KB |
Output is correct |
13 |
Correct |
22 ms |
5704 KB |
Output is correct |
14 |
Correct |
43 ms |
6736 KB |
Output is correct |
15 |
Correct |
34 ms |
6736 KB |
Output is correct |
16 |
Correct |
30 ms |
6692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
26 ms |
6492 KB |
Output is correct |
12 |
Correct |
27 ms |
4704 KB |
Output is correct |
13 |
Correct |
22 ms |
5704 KB |
Output is correct |
14 |
Correct |
43 ms |
6736 KB |
Output is correct |
15 |
Correct |
34 ms |
6736 KB |
Output is correct |
16 |
Correct |
30 ms |
6692 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
6748 KB |
Output is correct |
23 |
Correct |
32 ms |
6492 KB |
Output is correct |
24 |
Correct |
35 ms |
5208 KB |
Output is correct |
25 |
Correct |
56 ms |
6992 KB |
Output is correct |
26 |
Correct |
35 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
26 ms |
6492 KB |
Output is correct |
12 |
Correct |
27 ms |
4704 KB |
Output is correct |
13 |
Correct |
22 ms |
5704 KB |
Output is correct |
14 |
Correct |
43 ms |
6736 KB |
Output is correct |
15 |
Correct |
34 ms |
6736 KB |
Output is correct |
16 |
Correct |
30 ms |
6692 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
6748 KB |
Output is correct |
23 |
Correct |
32 ms |
6492 KB |
Output is correct |
24 |
Correct |
35 ms |
5208 KB |
Output is correct |
25 |
Correct |
56 ms |
6992 KB |
Output is correct |
26 |
Correct |
35 ms |
6748 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
3 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
36 ms |
7028 KB |
Output is correct |
35 |
Correct |
42 ms |
6740 KB |
Output is correct |
36 |
Correct |
50 ms |
7336 KB |
Output is correct |
37 |
Correct |
63 ms |
7512 KB |
Output is correct |
38 |
Correct |
39 ms |
7332 KB |
Output is correct |
39 |
Correct |
22 ms |
4696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
26 ms |
6492 KB |
Output is correct |
12 |
Correct |
27 ms |
4704 KB |
Output is correct |
13 |
Correct |
22 ms |
5704 KB |
Output is correct |
14 |
Correct |
43 ms |
6736 KB |
Output is correct |
15 |
Correct |
34 ms |
6736 KB |
Output is correct |
16 |
Correct |
30 ms |
6692 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
6748 KB |
Output is correct |
23 |
Correct |
32 ms |
6492 KB |
Output is correct |
24 |
Correct |
35 ms |
5208 KB |
Output is correct |
25 |
Correct |
56 ms |
6992 KB |
Output is correct |
26 |
Correct |
35 ms |
6748 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
3 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
36 ms |
7028 KB |
Output is correct |
35 |
Correct |
42 ms |
6740 KB |
Output is correct |
36 |
Correct |
50 ms |
7336 KB |
Output is correct |
37 |
Correct |
63 ms |
7512 KB |
Output is correct |
38 |
Correct |
39 ms |
7332 KB |
Output is correct |
39 |
Correct |
22 ms |
4696 KB |
Output is correct |
40 |
Correct |
1 ms |
532 KB |
Output is correct |
41 |
Correct |
1 ms |
604 KB |
Output is correct |
42 |
Correct |
1 ms |
604 KB |
Output is correct |
43 |
Correct |
1 ms |
604 KB |
Output is correct |
44 |
Correct |
45 ms |
7780 KB |
Output is correct |
45 |
Correct |
63 ms |
7888 KB |
Output is correct |
46 |
Correct |
59 ms |
7760 KB |
Output is correct |
47 |
Correct |
68 ms |
7920 KB |
Output is correct |
48 |
Correct |
44 ms |
7768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
728 KB |
Output is correct |
27 |
Correct |
2 ms |
604 KB |
Output is correct |
28 |
Correct |
2 ms |
740 KB |
Output is correct |
29 |
Correct |
2 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1 ms |
604 KB |
Output is correct |
32 |
Correct |
2 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
2 ms |
604 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
1 ms |
552 KB |
Output is correct |
39 |
Correct |
1 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
1 ms |
348 KB |
Output is correct |
45 |
Correct |
1 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
460 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
26 ms |
6492 KB |
Output is correct |
51 |
Correct |
27 ms |
4704 KB |
Output is correct |
52 |
Correct |
22 ms |
5704 KB |
Output is correct |
53 |
Correct |
43 ms |
6736 KB |
Output is correct |
54 |
Correct |
34 ms |
6736 KB |
Output is correct |
55 |
Correct |
30 ms |
6692 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
1 ms |
348 KB |
Output is correct |
61 |
Correct |
32 ms |
6748 KB |
Output is correct |
62 |
Correct |
32 ms |
6492 KB |
Output is correct |
63 |
Correct |
35 ms |
5208 KB |
Output is correct |
64 |
Correct |
56 ms |
6992 KB |
Output is correct |
65 |
Correct |
35 ms |
6748 KB |
Output is correct |
66 |
Correct |
0 ms |
348 KB |
Output is correct |
67 |
Correct |
0 ms |
348 KB |
Output is correct |
68 |
Correct |
0 ms |
348 KB |
Output is correct |
69 |
Correct |
0 ms |
348 KB |
Output is correct |
70 |
Correct |
3 ms |
604 KB |
Output is correct |
71 |
Correct |
0 ms |
348 KB |
Output is correct |
72 |
Correct |
1 ms |
348 KB |
Output is correct |
73 |
Correct |
36 ms |
7028 KB |
Output is correct |
74 |
Correct |
42 ms |
6740 KB |
Output is correct |
75 |
Correct |
50 ms |
7336 KB |
Output is correct |
76 |
Correct |
63 ms |
7512 KB |
Output is correct |
77 |
Correct |
39 ms |
7332 KB |
Output is correct |
78 |
Correct |
22 ms |
4696 KB |
Output is correct |
79 |
Correct |
1 ms |
532 KB |
Output is correct |
80 |
Correct |
1 ms |
604 KB |
Output is correct |
81 |
Correct |
1 ms |
604 KB |
Output is correct |
82 |
Correct |
1 ms |
604 KB |
Output is correct |
83 |
Correct |
45 ms |
7780 KB |
Output is correct |
84 |
Correct |
63 ms |
7888 KB |
Output is correct |
85 |
Correct |
59 ms |
7760 KB |
Output is correct |
86 |
Correct |
68 ms |
7920 KB |
Output is correct |
87 |
Correct |
44 ms |
7768 KB |
Output is correct |
88 |
Correct |
57 ms |
9552 KB |
Output is correct |
89 |
Correct |
68 ms |
9752 KB |
Output is correct |
90 |
Correct |
60 ms |
9808 KB |
Output is correct |
91 |
Correct |
75 ms |
9556 KB |
Output is correct |
92 |
Correct |
56 ms |
8232 KB |
Output is correct |
93 |
Correct |
65 ms |
8576 KB |
Output is correct |
94 |
Correct |
70 ms |
8304 KB |
Output is correct |
95 |
Correct |
65 ms |
9552 KB |
Output is correct |
96 |
Correct |
69 ms |
9812 KB |
Output is correct |
97 |
Correct |
49 ms |
9752 KB |
Output is correct |
98 |
Correct |
31 ms |
8224 KB |
Output is correct |
99 |
Correct |
60 ms |
8304 KB |
Output is correct |