Submission #858223

# Submission time Handle Problem Language Result Execution time Memory
858223 2023-10-07T16:14:35 Z samek08 Team Contest (JOI22_team) C++14
100 / 100
83 ms 14164 KB
#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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6616 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6608 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6612 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6612 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 1 ms 6612 KB Output is correct
24 Correct 1 ms 6488 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6616 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6608 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6612 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6612 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 1 ms 6612 KB Output is correct
24 Correct 1 ms 6488 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 3 ms 6616 KB Output is correct
27 Correct 3 ms 6744 KB Output is correct
28 Correct 3 ms 6744 KB Output is correct
29 Correct 3 ms 6748 KB Output is correct
30 Correct 2 ms 6492 KB Output is correct
31 Correct 2 ms 6664 KB Output is correct
32 Correct 3 ms 6744 KB Output is correct
33 Correct 2 ms 6748 KB Output is correct
34 Correct 3 ms 6620 KB Output is correct
35 Correct 1 ms 6488 KB Output is correct
36 Correct 2 ms 6492 KB Output is correct
37 Correct 2 ms 6620 KB Output is correct
38 Correct 3 ms 6748 KB Output is correct
39 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6604 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 29 ms 10824 KB Output is correct
12 Correct 31 ms 9576 KB Output is correct
13 Correct 26 ms 10240 KB Output is correct
14 Correct 49 ms 11020 KB Output is correct
15 Correct 38 ms 11164 KB Output is correct
16 Correct 35 ms 11024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6604 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 29 ms 10824 KB Output is correct
12 Correct 31 ms 9576 KB Output is correct
13 Correct 26 ms 10240 KB Output is correct
14 Correct 49 ms 11020 KB Output is correct
15 Correct 38 ms 11164 KB Output is correct
16 Correct 35 ms 11024 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 36 ms 11208 KB Output is correct
23 Correct 38 ms 11088 KB Output is correct
24 Correct 38 ms 9968 KB Output is correct
25 Correct 60 ms 11348 KB Output is correct
26 Correct 39 ms 11096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6604 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 29 ms 10824 KB Output is correct
12 Correct 31 ms 9576 KB Output is correct
13 Correct 26 ms 10240 KB Output is correct
14 Correct 49 ms 11020 KB Output is correct
15 Correct 38 ms 11164 KB Output is correct
16 Correct 35 ms 11024 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 36 ms 11208 KB Output is correct
23 Correct 38 ms 11088 KB Output is correct
24 Correct 38 ms 9968 KB Output is correct
25 Correct 60 ms 11348 KB Output is correct
26 Correct 39 ms 11096 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 6488 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 3 ms 6748 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6624 KB Output is correct
34 Correct 47 ms 11612 KB Output is correct
35 Correct 47 ms 11348 KB Output is correct
36 Correct 53 ms 11604 KB Output is correct
37 Correct 73 ms 11928 KB Output is correct
38 Correct 47 ms 11600 KB Output is correct
39 Correct 32 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6604 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 29 ms 10824 KB Output is correct
12 Correct 31 ms 9576 KB Output is correct
13 Correct 26 ms 10240 KB Output is correct
14 Correct 49 ms 11020 KB Output is correct
15 Correct 38 ms 11164 KB Output is correct
16 Correct 35 ms 11024 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 36 ms 11208 KB Output is correct
23 Correct 38 ms 11088 KB Output is correct
24 Correct 38 ms 9968 KB Output is correct
25 Correct 60 ms 11348 KB Output is correct
26 Correct 39 ms 11096 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 6488 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 3 ms 6748 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6624 KB Output is correct
34 Correct 47 ms 11612 KB Output is correct
35 Correct 47 ms 11348 KB Output is correct
36 Correct 53 ms 11604 KB Output is correct
37 Correct 73 ms 11928 KB Output is correct
38 Correct 47 ms 11600 KB Output is correct
39 Correct 32 ms 10064 KB Output is correct
40 Correct 2 ms 6488 KB Output is correct
41 Correct 2 ms 6748 KB Output is correct
42 Correct 2 ms 6748 KB Output is correct
43 Correct 2 ms 6748 KB Output is correct
44 Correct 50 ms 12220 KB Output is correct
45 Correct 70 ms 12260 KB Output is correct
46 Correct 64 ms 12108 KB Output is correct
47 Correct 83 ms 12372 KB Output is correct
48 Correct 48 ms 12308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6616 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6608 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6612 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6612 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 1 ms 6612 KB Output is correct
24 Correct 1 ms 6488 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 3 ms 6616 KB Output is correct
27 Correct 3 ms 6744 KB Output is correct
28 Correct 3 ms 6744 KB Output is correct
29 Correct 3 ms 6748 KB Output is correct
30 Correct 2 ms 6492 KB Output is correct
31 Correct 2 ms 6664 KB Output is correct
32 Correct 3 ms 6744 KB Output is correct
33 Correct 2 ms 6748 KB Output is correct
34 Correct 3 ms 6620 KB Output is correct
35 Correct 1 ms 6488 KB Output is correct
36 Correct 2 ms 6492 KB Output is correct
37 Correct 2 ms 6620 KB Output is correct
38 Correct 3 ms 6748 KB Output is correct
39 Correct 2 ms 6492 KB Output is correct
40 Correct 1 ms 6492 KB Output is correct
41 Correct 1 ms 6492 KB Output is correct
42 Correct 1 ms 6492 KB Output is correct
43 Correct 1 ms 6492 KB Output is correct
44 Correct 2 ms 6492 KB Output is correct
45 Correct 1 ms 6492 KB Output is correct
46 Correct 1 ms 6492 KB Output is correct
47 Correct 1 ms 6604 KB Output is correct
48 Correct 1 ms 6492 KB Output is correct
49 Correct 1 ms 6492 KB Output is correct
50 Correct 29 ms 10824 KB Output is correct
51 Correct 31 ms 9576 KB Output is correct
52 Correct 26 ms 10240 KB Output is correct
53 Correct 49 ms 11020 KB Output is correct
54 Correct 38 ms 11164 KB Output is correct
55 Correct 35 ms 11024 KB Output is correct
56 Correct 1 ms 6492 KB Output is correct
57 Correct 1 ms 6492 KB Output is correct
58 Correct 1 ms 6492 KB Output is correct
59 Correct 1 ms 6492 KB Output is correct
60 Correct 1 ms 6492 KB Output is correct
61 Correct 36 ms 11208 KB Output is correct
62 Correct 38 ms 11088 KB Output is correct
63 Correct 38 ms 9968 KB Output is correct
64 Correct 60 ms 11348 KB Output is correct
65 Correct 39 ms 11096 KB Output is correct
66 Correct 1 ms 6488 KB Output is correct
67 Correct 1 ms 6488 KB Output is correct
68 Correct 1 ms 6492 KB Output is correct
69 Correct 1 ms 6488 KB Output is correct
70 Correct 3 ms 6748 KB Output is correct
71 Correct 1 ms 6492 KB Output is correct
72 Correct 1 ms 6624 KB Output is correct
73 Correct 47 ms 11612 KB Output is correct
74 Correct 47 ms 11348 KB Output is correct
75 Correct 53 ms 11604 KB Output is correct
76 Correct 73 ms 11928 KB Output is correct
77 Correct 47 ms 11600 KB Output is correct
78 Correct 32 ms 10064 KB Output is correct
79 Correct 2 ms 6488 KB Output is correct
80 Correct 2 ms 6748 KB Output is correct
81 Correct 2 ms 6748 KB Output is correct
82 Correct 2 ms 6748 KB Output is correct
83 Correct 50 ms 12220 KB Output is correct
84 Correct 70 ms 12260 KB Output is correct
85 Correct 64 ms 12108 KB Output is correct
86 Correct 83 ms 12372 KB Output is correct
87 Correct 48 ms 12308 KB Output is correct
88 Correct 63 ms 14012 KB Output is correct
89 Correct 71 ms 14156 KB Output is correct
90 Correct 63 ms 14164 KB Output is correct
91 Correct 81 ms 14020 KB Output is correct
92 Correct 62 ms 12604 KB Output is correct
93 Correct 71 ms 12880 KB Output is correct
94 Correct 75 ms 12884 KB Output is correct
95 Correct 63 ms 13916 KB Output is correct
96 Correct 76 ms 14160 KB Output is correct
97 Correct 50 ms 14100 KB Output is correct
98 Correct 34 ms 12624 KB Output is correct
99 Correct 69 ms 12628 KB Output is correct