이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast,unroll-loops")
#define pii pair<int,int>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
#define f first
#define s second
#define pii pair<int,int>
template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;}
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;
const int mod= 1e9 +7;
const int N=1e5*4;
int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}
vector<int>a(N+1),b(N+1);
vector<pii>c;
pair<int,pii> t[N*4];
void build(int v,int tl,int tr){
	
	if(tl==tr){
		t[v].f = c[tl-1].f;
		t[v].s.f = a[c[tl-1].s];
		t[v].s.s = b[c[tl-1].s];
		return;
	}
	int tm = (tl+tr)/2;
	build(v*2,tl,tm);
	build(v*2+1,tm+1,tr);
	t[v].f = max(t[v*2].f,t[v*2+1].f);
	t[v].s.f = min(t[v*2].s.f,t[v*2+1].s.f);
	t[v].s.s = min(t[v*2].s.s,t[v*2+1].s.s);
}
int get(int val1,int val2,int v,int tl,int tr){
	
	if(t[v].s.f>=val1||t[v].s.s>=val2){
		return 0;
	}
	if(tl==tr){
		return t[v].f;
	}	
	int tm = (tl+tr)/2;
	
	if(t[v*2+1].s.f<val1&&t[v*2+1].s.s<val2){
		return get(val1,val2,v*2+1,tm+1,tr);
	}
	else return get(val1,val2,v*2,tl,tm);
		
}
void solve(){
	int n,m,k;
	cin>>n;
	int sum = 0;
	for(int i = 1;i<=n;i++){
		cin>>a[i]>>b[i]>>k;
		c.pb({k,i});
	}
	int mx = -1;
	vector<pii>c1;
	c1 = c;
	sort(all(c));
	
	build(1,1,n);
	
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			if(i==j)continue;
			if(a[i]>a[j]&&b[j]>b[i]){
				sum = a[i] + b[j];
				int h = get(a[i],b[j],1,1,n);
				if(h!=0&&c1[i-1].f<h&&c1[j-1].f<h){
					sum += h;
					//~ cout<<i<<" "<<j<<" "<<h<<"\n";
					umax(mx,sum);
				}
			}
		}
	}
	
	cout<<mx<<"\n";
}
 signed main()
{
//	freopen("seq.in", "r", stdin);
//  freopen("seq.out", "w", stdout);
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int tt=1;//cin>>tt;
	while(tt--)solve();
}
컴파일 시 표준 에러 (stderr) 메시지
team.cpp: In function 'void solve()':
team.cpp:70:8: warning: unused variable 'm' [-Wunused-variable]
   70 |  int n,m,k;
      |        ^| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |