Submission #696284

# Submission time Handle Problem Language Result Execution time Memory
696284 2023-02-06T07:02:21 Z ld_minh4354 Team Contest (JOI22_team) C++17
0 / 100
31 ms 3844 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back



signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//	freopen("input.000","r",stdin);
//	freopen("output.000","w",stdout);
//	srand((unsigned)time(NULL));
//	rand()

	int n,i,max_x1,max_x2,max_y1,max_y2,cur_num,cur_id,j,ans;
	static pair<int,pair<int,int>> a[150005];
	bool max_xy;
	
	cin>>n;
	for (i=1;i<n+1;i++) cin>>a[i].se.fi>>a[i].se.se>>a[i].fi;
	sort(a+1,a+n+1);
	
//	for (i=1;i<n+1;i++) cout<<y[i].fi<<y[i].se.fi<<y[i].se.se<<"\n";
	
	max_x1=max_x2=max_y1=max_y2=0;
	cur_num=a[1].fi;
	cur_id=1;
	ans=-1;
	
	for (i=1;i<n+1;i++)
	{
		if (cur_num < a[i].fi)
		{
			for (j=cur_id; j<i; j++)
			{
				if (a[j].se.fi >= max_x1)
				{
					max_x2=max_x1;
					max_x1=a[j].se.fi;
				}
				else if (a[j].se.fi > max_x2) max_x2=a[j].se.fi;
				
				
				if (a[j].se.se >= max_y1)
				{
					max_y2=max_y1;
					max_y1=a[j].se.se;
				}
				else if (a[j].se.se > max_y2) max_y2=a[j].se.se;
				
				if (a[j].se.fi==max_x1 and a[j].se.se==max_y1) max_xy=true;else max_xy=false;
			}
			
			cur_id=i;
			cur_num=a[i].fi;
		}
		
//		cout<<i<<" "<<max_x1<<" "<<max_x2<<" "<<max_y1<<" "<<max_y2<<" "<<max_xy<<"\n";
		
		if (max_xy)
		{
			if (a[i].se.fi < max_x1 and a[i].se.se < max_y2)
			ans=max(ans,a[i].fi + max_x1 + max_y2);//cout<<ans<<" "<<a[i].fi<<" "<<max_x1<<" "<<max_y2<<"\n";
			
			if (a[i].se.fi < max_x2 and a[i].se.se < max_y1)
			ans=max(ans,a[i].fi + max_x2 + max_y1);//cout<<ans<<" "<<a[i].fi<<" "<<max_x2<<" "<<max_y1<<"\n";
		}
		else if (a[i].se.fi < max_x1 and a[i].se.se < max_y1)
			 ans=max(ans,a[i].fi + max_x1 + max_y1);//cout<<ans<<" "<<a[i].fi<<" "<<max_x1<<" "<<max_y1<<"\n";
			 
	}
	
	cout<<ans;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:64:3: warning: 'max_xy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   64 |   if (max_xy)
      |   ^~
# 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 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 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 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 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 1 ms 228 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 31 ms 3844 KB Output is correct
12 Incorrect 21 ms 2644 KB Output isn't correct
13 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 1 ms 228 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 31 ms 3844 KB Output is correct
12 Incorrect 21 ms 2644 KB Output isn't correct
13 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 1 ms 228 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 31 ms 3844 KB Output is correct
12 Incorrect 21 ms 2644 KB Output isn't correct
13 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 1 ms 228 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 31 ms 3844 KB Output is correct
12 Incorrect 21 ms 2644 KB Output isn't correct
13 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 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -