Submission #634505

# Submission time Handle Problem Language Result Execution time Memory
634505 2022-08-24T13:32:49 Z LittleCube Team Contest (JOI22_team) C++14
55 / 100
2000 ms 6024 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

struct ppl
{
	ll x, y, z;
} a[150005];

int N;
map<int, int> mp;
ll ans = -1, bit[150005];

void init()
{
	for(int i = 1; i <= N; i++)
		bit[i] = -1e10;
}

void modify(int pos, ll val)
{
	for(int i = pos; i <= N; i += (i & -i))
		bit[i] = max(bit[i], val);
}

ll query(int pos)
{
	ll ans = -1e10;
	for(int i = pos; i > 0; i -= (i & -i))
		ans = max(ans, bit[i]);
	return ans;
}

int ypos[150005];

signed main()
{
	cin >> N;
	for(int i = 1; i <= N; i++)
		cin >> a[i].x >> a[i].y >> a[i].z;
	sort(a + 1, a + 1 + N, [&](ppl p, ppl q){ return make_tuple(p.x, p.y, p.z) < make_tuple(q.x, q.y, q.z); });

	N = unique(a + 1, a + 1 + N, [&](ppl p, ppl q){ return make_tuple(p.x, p.y, p.z) == make_tuple(q.x, q.y, q.z); }) - a - 1;
	


	int t = 2;
	while(t--)
	{	
		vector<int> v;
		for(int i = 1; i <= N; i++)
			v.emplace_back(a[i].y);
		sort(v.begin(), v.end());
		for(int i = 1; i <= N; i++)
			ypos[i] = lower_bound(v.begin(), v.end(), a[i].y) - v.begin() + 1;
		init();

		for(int i = 1, nxt = 1; i <= N; i++)
		{	
			while(a[nxt].x < a[i].x)
			{
				modify(ypos[nxt], a[nxt].z);
				nxt++;
			}

			for(int j = 1; a[j].x < a[i].x; j++)
			{
				if(a[j].y <= a[i].y)
					continue;
				ll mxz = query(ypos[j] - 1);
				if(mxz > max(a[j].z, a[i].z))
					ans = max(ans, a[i].x + a[j].y + mxz);
			}
		}
		for(int i = 1; i <= N; i++)
			swap(a[i].y, a[i].z);
	}
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 140 ms 476 KB Output is correct
27 Correct 118 ms 476 KB Output is correct
28 Correct 101 ms 468 KB Output is correct
29 Correct 69 ms 476 KB Output is correct
30 Correct 45 ms 432 KB Output is correct
31 Correct 135 ms 468 KB Output is correct
32 Correct 125 ms 468 KB Output is correct
33 Correct 16 ms 472 KB Output is correct
34 Correct 16 ms 468 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 15 ms 496 KB Output is correct
38 Correct 16 ms 468 KB Output is correct
39 Correct 20 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 3800 KB Output is correct
12 Correct 49 ms 2640 KB Output is correct
13 Correct 54 ms 3180 KB Output is correct
14 Correct 63 ms 3760 KB Output is correct
15 Correct 61 ms 3780 KB Output is correct
16 Correct 60 ms 3784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 3800 KB Output is correct
12 Correct 49 ms 2640 KB Output is correct
13 Correct 54 ms 3180 KB Output is correct
14 Correct 63 ms 3760 KB Output is correct
15 Correct 61 ms 3780 KB Output is correct
16 Correct 60 ms 3784 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 18 ms 400 KB Output is correct
22 Correct 297 ms 3852 KB Output is correct
23 Correct 92 ms 3704 KB Output is correct
24 Correct 64 ms 2880 KB Output is correct
25 Correct 81 ms 3740 KB Output is correct
26 Correct 85 ms 3744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 3800 KB Output is correct
12 Correct 49 ms 2640 KB Output is correct
13 Correct 54 ms 3180 KB Output is correct
14 Correct 63 ms 3760 KB Output is correct
15 Correct 61 ms 3780 KB Output is correct
16 Correct 60 ms 3784 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 18 ms 400 KB Output is correct
22 Correct 297 ms 3852 KB Output is correct
23 Correct 92 ms 3704 KB Output is correct
24 Correct 64 ms 2880 KB Output is correct
25 Correct 81 ms 3740 KB Output is correct
26 Correct 85 ms 3744 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 101 ms 468 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Execution timed out 2074 ms 6024 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 68 ms 3800 KB Output is correct
12 Correct 49 ms 2640 KB Output is correct
13 Correct 54 ms 3180 KB Output is correct
14 Correct 63 ms 3760 KB Output is correct
15 Correct 61 ms 3780 KB Output is correct
16 Correct 60 ms 3784 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 18 ms 400 KB Output is correct
22 Correct 297 ms 3852 KB Output is correct
23 Correct 92 ms 3704 KB Output is correct
24 Correct 64 ms 2880 KB Output is correct
25 Correct 81 ms 3740 KB Output is correct
26 Correct 85 ms 3744 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 101 ms 468 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Execution timed out 2074 ms 6024 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 140 ms 476 KB Output is correct
27 Correct 118 ms 476 KB Output is correct
28 Correct 101 ms 468 KB Output is correct
29 Correct 69 ms 476 KB Output is correct
30 Correct 45 ms 432 KB Output is correct
31 Correct 135 ms 468 KB Output is correct
32 Correct 125 ms 468 KB Output is correct
33 Correct 16 ms 472 KB Output is correct
34 Correct 16 ms 468 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 15 ms 496 KB Output is correct
38 Correct 16 ms 468 KB Output is correct
39 Correct 20 ms 404 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 68 ms 3800 KB Output is correct
51 Correct 49 ms 2640 KB Output is correct
52 Correct 54 ms 3180 KB Output is correct
53 Correct 63 ms 3760 KB Output is correct
54 Correct 61 ms 3780 KB Output is correct
55 Correct 60 ms 3784 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 18 ms 400 KB Output is correct
61 Correct 297 ms 3852 KB Output is correct
62 Correct 92 ms 3704 KB Output is correct
63 Correct 64 ms 2880 KB Output is correct
64 Correct 81 ms 3740 KB Output is correct
65 Correct 85 ms 3744 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 2 ms 340 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 101 ms 468 KB Output is correct
71 Correct 2 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Execution timed out 2074 ms 6024 KB Time limit exceeded
74 Halted 0 ms 0 KB -