Submission #618621

# Submission time Handle Problem Language Result Execution time Memory
618621 2022-08-02T06:12:39 Z CSQ31 Team Contest (JOI22_team) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
typedef pair<int,int> pii;
typedef long long int ll;
const int MAXN = 5e5;
array<ll,3>pts[MAXN];
int bmx[MAXN];
//i have rectangle queries but i cant do it offline?
//i can but its double log on 2s
//ok try n^2 first
int main()
{
	owo
	int n;
	cin>>n;
	vector<array<ll,3>>a(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	sort(all(a),[&](array<ll,3>i,array<ll,3>j){return j[0] > i[0];});
	//cout<<"sorted"<<'\n';
	//for(int i=0;i<n;i++)cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<'\n';
	for(int i=0;i<n;i++){
		pts[i][2] = -2e9;
		pts[i][0] = a[i][1];
		for(int j=0;j<n;j++){
			if(a[j][0] >= a[i][0]){}
			else continue;
			if(a[j][1] < a[i][1])pts[i][1] = max(pts[i][1],a[j][2]);
		}
		if(pts[i][1] > a[i][2])pts[i][2] = pts[i][1] + pts[i][0]; //the value
		//cout<<pts[i][0]<<" "<<pts[i][1]<<" "<<pts[i][2]<<'\n';
	}
	ll ans = -1;
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			if(a[i][0] <= a[j][0])continue;
			if(pts[j][2] <0)continue;
			if(pts[j][0] > a[i][1] && pts[j][1] >a[i][2]){
				ans = max(ans,a[i][0] + pts[j][2]);
			}
			
		}
	}
	cout<<ans;
	
	
	
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -