#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)
using namespace std;
ll n;
ll X[150009];
ll Y[150009];
ll Z[150009];
ll ox[150009];
ll oy[150009];
ll oz[150009];
ll mx[4009][4009];
int main()
{
d3
cin >> n;
set<ll> s1 , s2 , s3;
map<ll,ll> mp1 , mp2 , mp3;
map<pair<pll,ll>,ll> mp;
int i = 0;
while(n--)
{
ll x , y , z;
cin >> x >> y >> z;
if(mp[{{x,y},z}])
continue;
mp[{{x,y},z}]=1;
X[i]=x;
Y[i]=y;
Z[i]=z;
s1.in(X[i]);
s2.in(Y[i]);
s3.in(Z[i]);
i++;
}
n=i;
ll t = 0;
for(auto it : s1)
{
mp1[it]=t;
ox[t]=it;
t++;
}
t=0;
for(auto it : s2)
{
mp2[it]=t;
oy[t]=it;
t++;
}
t=0;
for(auto it : s3)
{
mp3[it]=t;
oz[t]=it;
t++;
}
for(int i = 0 ; n>i ; i++)
{
X[i]=mp1[X[i]];
Y[i]=mp2[Y[i]];
Z[i]=mp3[Z[i]];
mx[X[i]][Y[i]]=max(mx[X[i]][Y[i]],Z[i]);
}
for(int i = 1 ; 4009 > i ; i++)
mx[i][0]=max(mx[i][0],mx[i-1][0]);
for(int i = 1 ; 4009 > i ; i++)
mx[0][i]=max(mx[0][i],mx[0][i-1]);
for(int i = 1 ; 4009>i ; i++)
for(int j = 1 ; 4009>j ; j++)
mx[i][j]=max(mx[i][j],max(mx[i-1][j],mx[i][j-1]));
ll ans = -1;
for(int i = 0 ; n>i ; i++)
{
for(int j = 0 ; n>j ; j++)
{
if(i==j)
continue;
if(X[i]>X[j]&&Y[j]>Y[i])
{
if(max(Z[i],Z[j])>=mx[X[i]-1][Y[j]-1])
continue;
ans=max(ans,ox[X[i]]+oy[Y[j]]+oz[mx[X[i]-1][Y[j]-1]]);
}
}
}
cans
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
131924 KB |
Output is correct |
2 |
Correct |
77 ms |
131920 KB |
Output is correct |
3 |
Correct |
66 ms |
131696 KB |
Output is correct |
4 |
Correct |
68 ms |
131832 KB |
Output is correct |
5 |
Correct |
63 ms |
131920 KB |
Output is correct |
6 |
Correct |
62 ms |
131892 KB |
Output is correct |
7 |
Correct |
60 ms |
131920 KB |
Output is correct |
8 |
Correct |
63 ms |
131932 KB |
Output is correct |
9 |
Correct |
61 ms |
131820 KB |
Output is correct |
10 |
Correct |
61 ms |
131920 KB |
Output is correct |
11 |
Correct |
86 ms |
131924 KB |
Output is correct |
12 |
Correct |
67 ms |
131696 KB |
Output is correct |
13 |
Correct |
62 ms |
131920 KB |
Output is correct |
14 |
Correct |
66 ms |
131840 KB |
Output is correct |
15 |
Correct |
65 ms |
131780 KB |
Output is correct |
16 |
Correct |
61 ms |
131920 KB |
Output is correct |
17 |
Correct |
66 ms |
132008 KB |
Output is correct |
18 |
Correct |
68 ms |
131928 KB |
Output is correct |
19 |
Correct |
68 ms |
131924 KB |
Output is correct |
20 |
Correct |
67 ms |
131864 KB |
Output is correct |
21 |
Correct |
67 ms |
131988 KB |
Output is correct |
22 |
Correct |
64 ms |
132016 KB |
Output is correct |
23 |
Correct |
65 ms |
131920 KB |
Output is correct |
24 |
Correct |
71 ms |
131920 KB |
Output is correct |
25 |
Correct |
68 ms |
131920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
131924 KB |
Output is correct |
2 |
Correct |
77 ms |
131920 KB |
Output is correct |
3 |
Correct |
66 ms |
131696 KB |
Output is correct |
4 |
Correct |
68 ms |
131832 KB |
Output is correct |
5 |
Correct |
63 ms |
131920 KB |
Output is correct |
6 |
Correct |
62 ms |
131892 KB |
Output is correct |
7 |
Correct |
60 ms |
131920 KB |
Output is correct |
8 |
Correct |
63 ms |
131932 KB |
Output is correct |
9 |
Correct |
61 ms |
131820 KB |
Output is correct |
10 |
Correct |
61 ms |
131920 KB |
Output is correct |
11 |
Correct |
86 ms |
131924 KB |
Output is correct |
12 |
Correct |
67 ms |
131696 KB |
Output is correct |
13 |
Correct |
62 ms |
131920 KB |
Output is correct |
14 |
Correct |
66 ms |
131840 KB |
Output is correct |
15 |
Correct |
65 ms |
131780 KB |
Output is correct |
16 |
Correct |
61 ms |
131920 KB |
Output is correct |
17 |
Correct |
66 ms |
132008 KB |
Output is correct |
18 |
Correct |
68 ms |
131928 KB |
Output is correct |
19 |
Correct |
68 ms |
131924 KB |
Output is correct |
20 |
Correct |
67 ms |
131864 KB |
Output is correct |
21 |
Correct |
67 ms |
131988 KB |
Output is correct |
22 |
Correct |
64 ms |
132016 KB |
Output is correct |
23 |
Correct |
65 ms |
131920 KB |
Output is correct |
24 |
Correct |
71 ms |
131920 KB |
Output is correct |
25 |
Correct |
68 ms |
131920 KB |
Output is correct |
26 |
Correct |
144 ms |
133456 KB |
Output is correct |
27 |
Correct |
137 ms |
132948 KB |
Output is correct |
28 |
Correct |
128 ms |
133096 KB |
Output is correct |
29 |
Correct |
122 ms |
132944 KB |
Output is correct |
30 |
Correct |
94 ms |
132572 KB |
Output is correct |
31 |
Correct |
133 ms |
132536 KB |
Output is correct |
32 |
Correct |
123 ms |
132212 KB |
Output is correct |
33 |
Correct |
77 ms |
132436 KB |
Output is correct |
34 |
Correct |
115 ms |
133452 KB |
Output is correct |
35 |
Correct |
67 ms |
131968 KB |
Output is correct |
36 |
Correct |
77 ms |
132052 KB |
Output is correct |
37 |
Correct |
83 ms |
132692 KB |
Output is correct |
38 |
Correct |
79 ms |
132540 KB |
Output is correct |
39 |
Correct |
73 ms |
131924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
131920 KB |
Output is correct |
2 |
Correct |
69 ms |
131776 KB |
Output is correct |
3 |
Correct |
63 ms |
131808 KB |
Output is correct |
4 |
Correct |
61 ms |
131920 KB |
Output is correct |
5 |
Correct |
61 ms |
131920 KB |
Output is correct |
6 |
Correct |
69 ms |
131824 KB |
Output is correct |
7 |
Correct |
66 ms |
131920 KB |
Output is correct |
8 |
Correct |
65 ms |
131924 KB |
Output is correct |
9 |
Correct |
61 ms |
131920 KB |
Output is correct |
10 |
Correct |
68 ms |
131924 KB |
Output is correct |
11 |
Correct |
83 ms |
132676 KB |
Output is correct |
12 |
Correct |
77 ms |
132432 KB |
Output is correct |
13 |
Correct |
78 ms |
132436 KB |
Output is correct |
14 |
Correct |
81 ms |
132692 KB |
Output is correct |
15 |
Correct |
84 ms |
132692 KB |
Output is correct |
16 |
Correct |
79 ms |
132688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
131920 KB |
Output is correct |
2 |
Correct |
69 ms |
131776 KB |
Output is correct |
3 |
Correct |
63 ms |
131808 KB |
Output is correct |
4 |
Correct |
61 ms |
131920 KB |
Output is correct |
5 |
Correct |
61 ms |
131920 KB |
Output is correct |
6 |
Correct |
69 ms |
131824 KB |
Output is correct |
7 |
Correct |
66 ms |
131920 KB |
Output is correct |
8 |
Correct |
65 ms |
131924 KB |
Output is correct |
9 |
Correct |
61 ms |
131920 KB |
Output is correct |
10 |
Correct |
68 ms |
131924 KB |
Output is correct |
11 |
Correct |
83 ms |
132676 KB |
Output is correct |
12 |
Correct |
77 ms |
132432 KB |
Output is correct |
13 |
Correct |
78 ms |
132436 KB |
Output is correct |
14 |
Correct |
81 ms |
132692 KB |
Output is correct |
15 |
Correct |
84 ms |
132692 KB |
Output is correct |
16 |
Correct |
79 ms |
132688 KB |
Output is correct |
17 |
Correct |
68 ms |
131924 KB |
Output is correct |
18 |
Correct |
69 ms |
131920 KB |
Output is correct |
19 |
Correct |
69 ms |
131920 KB |
Output is correct |
20 |
Correct |
74 ms |
131876 KB |
Output is correct |
21 |
Correct |
100 ms |
132056 KB |
Output is correct |
22 |
Correct |
348 ms |
133712 KB |
Output is correct |
23 |
Correct |
97 ms |
132948 KB |
Output is correct |
24 |
Correct |
90 ms |
132688 KB |
Output is correct |
25 |
Correct |
94 ms |
133072 KB |
Output is correct |
26 |
Correct |
90 ms |
132944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
131920 KB |
Output is correct |
2 |
Correct |
69 ms |
131776 KB |
Output is correct |
3 |
Correct |
63 ms |
131808 KB |
Output is correct |
4 |
Correct |
61 ms |
131920 KB |
Output is correct |
5 |
Correct |
61 ms |
131920 KB |
Output is correct |
6 |
Correct |
69 ms |
131824 KB |
Output is correct |
7 |
Correct |
66 ms |
131920 KB |
Output is correct |
8 |
Correct |
65 ms |
131924 KB |
Output is correct |
9 |
Correct |
61 ms |
131920 KB |
Output is correct |
10 |
Correct |
68 ms |
131924 KB |
Output is correct |
11 |
Correct |
83 ms |
132676 KB |
Output is correct |
12 |
Correct |
77 ms |
132432 KB |
Output is correct |
13 |
Correct |
78 ms |
132436 KB |
Output is correct |
14 |
Correct |
81 ms |
132692 KB |
Output is correct |
15 |
Correct |
84 ms |
132692 KB |
Output is correct |
16 |
Correct |
79 ms |
132688 KB |
Output is correct |
17 |
Correct |
68 ms |
131924 KB |
Output is correct |
18 |
Correct |
69 ms |
131920 KB |
Output is correct |
19 |
Correct |
69 ms |
131920 KB |
Output is correct |
20 |
Correct |
74 ms |
131876 KB |
Output is correct |
21 |
Correct |
100 ms |
132056 KB |
Output is correct |
22 |
Correct |
348 ms |
133712 KB |
Output is correct |
23 |
Correct |
97 ms |
132948 KB |
Output is correct |
24 |
Correct |
90 ms |
132688 KB |
Output is correct |
25 |
Correct |
94 ms |
133072 KB |
Output is correct |
26 |
Correct |
90 ms |
132944 KB |
Output is correct |
27 |
Correct |
70 ms |
131924 KB |
Output is correct |
28 |
Correct |
70 ms |
131924 KB |
Output is correct |
29 |
Correct |
65 ms |
131800 KB |
Output is correct |
30 |
Correct |
64 ms |
131924 KB |
Output is correct |
31 |
Correct |
110 ms |
132184 KB |
Output is correct |
32 |
Correct |
64 ms |
131920 KB |
Output is correct |
33 |
Correct |
73 ms |
131932 KB |
Output is correct |
34 |
Execution timed out |
2089 ms |
145744 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
131920 KB |
Output is correct |
2 |
Correct |
69 ms |
131776 KB |
Output is correct |
3 |
Correct |
63 ms |
131808 KB |
Output is correct |
4 |
Correct |
61 ms |
131920 KB |
Output is correct |
5 |
Correct |
61 ms |
131920 KB |
Output is correct |
6 |
Correct |
69 ms |
131824 KB |
Output is correct |
7 |
Correct |
66 ms |
131920 KB |
Output is correct |
8 |
Correct |
65 ms |
131924 KB |
Output is correct |
9 |
Correct |
61 ms |
131920 KB |
Output is correct |
10 |
Correct |
68 ms |
131924 KB |
Output is correct |
11 |
Correct |
83 ms |
132676 KB |
Output is correct |
12 |
Correct |
77 ms |
132432 KB |
Output is correct |
13 |
Correct |
78 ms |
132436 KB |
Output is correct |
14 |
Correct |
81 ms |
132692 KB |
Output is correct |
15 |
Correct |
84 ms |
132692 KB |
Output is correct |
16 |
Correct |
79 ms |
132688 KB |
Output is correct |
17 |
Correct |
68 ms |
131924 KB |
Output is correct |
18 |
Correct |
69 ms |
131920 KB |
Output is correct |
19 |
Correct |
69 ms |
131920 KB |
Output is correct |
20 |
Correct |
74 ms |
131876 KB |
Output is correct |
21 |
Correct |
100 ms |
132056 KB |
Output is correct |
22 |
Correct |
348 ms |
133712 KB |
Output is correct |
23 |
Correct |
97 ms |
132948 KB |
Output is correct |
24 |
Correct |
90 ms |
132688 KB |
Output is correct |
25 |
Correct |
94 ms |
133072 KB |
Output is correct |
26 |
Correct |
90 ms |
132944 KB |
Output is correct |
27 |
Correct |
70 ms |
131924 KB |
Output is correct |
28 |
Correct |
70 ms |
131924 KB |
Output is correct |
29 |
Correct |
65 ms |
131800 KB |
Output is correct |
30 |
Correct |
64 ms |
131924 KB |
Output is correct |
31 |
Correct |
110 ms |
132184 KB |
Output is correct |
32 |
Correct |
64 ms |
131920 KB |
Output is correct |
33 |
Correct |
73 ms |
131932 KB |
Output is correct |
34 |
Execution timed out |
2089 ms |
145744 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
131924 KB |
Output is correct |
2 |
Correct |
77 ms |
131920 KB |
Output is correct |
3 |
Correct |
66 ms |
131696 KB |
Output is correct |
4 |
Correct |
68 ms |
131832 KB |
Output is correct |
5 |
Correct |
63 ms |
131920 KB |
Output is correct |
6 |
Correct |
62 ms |
131892 KB |
Output is correct |
7 |
Correct |
60 ms |
131920 KB |
Output is correct |
8 |
Correct |
63 ms |
131932 KB |
Output is correct |
9 |
Correct |
61 ms |
131820 KB |
Output is correct |
10 |
Correct |
61 ms |
131920 KB |
Output is correct |
11 |
Correct |
86 ms |
131924 KB |
Output is correct |
12 |
Correct |
67 ms |
131696 KB |
Output is correct |
13 |
Correct |
62 ms |
131920 KB |
Output is correct |
14 |
Correct |
66 ms |
131840 KB |
Output is correct |
15 |
Correct |
65 ms |
131780 KB |
Output is correct |
16 |
Correct |
61 ms |
131920 KB |
Output is correct |
17 |
Correct |
66 ms |
132008 KB |
Output is correct |
18 |
Correct |
68 ms |
131928 KB |
Output is correct |
19 |
Correct |
68 ms |
131924 KB |
Output is correct |
20 |
Correct |
67 ms |
131864 KB |
Output is correct |
21 |
Correct |
67 ms |
131988 KB |
Output is correct |
22 |
Correct |
64 ms |
132016 KB |
Output is correct |
23 |
Correct |
65 ms |
131920 KB |
Output is correct |
24 |
Correct |
71 ms |
131920 KB |
Output is correct |
25 |
Correct |
68 ms |
131920 KB |
Output is correct |
26 |
Correct |
144 ms |
133456 KB |
Output is correct |
27 |
Correct |
137 ms |
132948 KB |
Output is correct |
28 |
Correct |
128 ms |
133096 KB |
Output is correct |
29 |
Correct |
122 ms |
132944 KB |
Output is correct |
30 |
Correct |
94 ms |
132572 KB |
Output is correct |
31 |
Correct |
133 ms |
132536 KB |
Output is correct |
32 |
Correct |
123 ms |
132212 KB |
Output is correct |
33 |
Correct |
77 ms |
132436 KB |
Output is correct |
34 |
Correct |
115 ms |
133452 KB |
Output is correct |
35 |
Correct |
67 ms |
131968 KB |
Output is correct |
36 |
Correct |
77 ms |
132052 KB |
Output is correct |
37 |
Correct |
83 ms |
132692 KB |
Output is correct |
38 |
Correct |
79 ms |
132540 KB |
Output is correct |
39 |
Correct |
73 ms |
131924 KB |
Output is correct |
40 |
Correct |
72 ms |
131920 KB |
Output is correct |
41 |
Correct |
69 ms |
131776 KB |
Output is correct |
42 |
Correct |
63 ms |
131808 KB |
Output is correct |
43 |
Correct |
61 ms |
131920 KB |
Output is correct |
44 |
Correct |
61 ms |
131920 KB |
Output is correct |
45 |
Correct |
69 ms |
131824 KB |
Output is correct |
46 |
Correct |
66 ms |
131920 KB |
Output is correct |
47 |
Correct |
65 ms |
131924 KB |
Output is correct |
48 |
Correct |
61 ms |
131920 KB |
Output is correct |
49 |
Correct |
68 ms |
131924 KB |
Output is correct |
50 |
Correct |
83 ms |
132676 KB |
Output is correct |
51 |
Correct |
77 ms |
132432 KB |
Output is correct |
52 |
Correct |
78 ms |
132436 KB |
Output is correct |
53 |
Correct |
81 ms |
132692 KB |
Output is correct |
54 |
Correct |
84 ms |
132692 KB |
Output is correct |
55 |
Correct |
79 ms |
132688 KB |
Output is correct |
56 |
Correct |
68 ms |
131924 KB |
Output is correct |
57 |
Correct |
69 ms |
131920 KB |
Output is correct |
58 |
Correct |
69 ms |
131920 KB |
Output is correct |
59 |
Correct |
74 ms |
131876 KB |
Output is correct |
60 |
Correct |
100 ms |
132056 KB |
Output is correct |
61 |
Correct |
348 ms |
133712 KB |
Output is correct |
62 |
Correct |
97 ms |
132948 KB |
Output is correct |
63 |
Correct |
90 ms |
132688 KB |
Output is correct |
64 |
Correct |
94 ms |
133072 KB |
Output is correct |
65 |
Correct |
90 ms |
132944 KB |
Output is correct |
66 |
Correct |
70 ms |
131924 KB |
Output is correct |
67 |
Correct |
70 ms |
131924 KB |
Output is correct |
68 |
Correct |
65 ms |
131800 KB |
Output is correct |
69 |
Correct |
64 ms |
131924 KB |
Output is correct |
70 |
Correct |
110 ms |
132184 KB |
Output is correct |
71 |
Correct |
64 ms |
131920 KB |
Output is correct |
72 |
Correct |
73 ms |
131932 KB |
Output is correct |
73 |
Execution timed out |
2089 ms |
145744 KB |
Time limit exceeded |
74 |
Halted |
0 ms |
0 KB |
- |