#include <bits/stdc++.h>
bool home = 1;
using namespace std;
struct T {
int x;
int y;
int z;
};
bool cmp_x_inv(T a,T b) {
return a.x>b.x;
}
typedef long long ll;
const int N=150000+7;
const int INF=(int)1e9+7;
int n;
T a[N];
signed main() {
#ifdef ONLINE_JUDGE
home = 0;
#endif
home=0;
if (home) {
freopen("I_am_iron_man", "r", stdin);
}
else {
ios::sync_with_stdio(0); cin.tie(0);
}
cin>>n;
for (int i=1;i<=n;i++) {
cin>>a[i].x>>a[i].y>>a[i].z;
}
{
map<int, int> tx,ty,tz;
for (int i=1;i<=n;i++) tx[a[i].x]=0,ty[a[i].y]=0,tz[a[i].z]=0;
int ind;
ind=0; for (auto &it:tx)it.second=++ind;
ind=0; for (auto &it:ty)it.second=++ind;
ind=0; for (auto &it:tz)it.second=++ind;
for (int i=1;i<=n;i++) a[i].x=tx[a[i].x], a[i].y=ty[a[i].y], a[i].z=tz[a[i].z];
}
sort(a+1,a+n+1,cmp_x_inv);
int print=-1;
for (int ITER=0;ITER<2;ITER++) {
int last=n;
while(last>=1){
int first=last;
while(first-1>=1&&a[first-1].x==a[first].x) first--;
for (int i=first;i<=last;i++) {
int best=-INF;
int y=a[i].y,z=a[i].z;
for (int j=last+1;j<=n;j++) {
if (a[j].y<=y) continue;
int sol=-INF;
for (int k=j+1;k<=n;k++) {
if (a[j].y>a[k].y) {
sol=max(sol,a[k].z);
}
}
if (sol>max(z,a[j].z)) {
best=max(best,sol+a[j].y);
}
}
print=max(print,best+a[i].x);
}
last=first-1;
}
for (int i=1;i<=n;i++) swap(a[i].y,a[i].z);
}
cout<<print<<"\n";
}
Compilation message
team.cpp: In function 'int main()':
team.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | freopen("I_am_iron_man", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |