Submission #892182

# Submission time Handle Problem Language Result Execution time Memory
892182 2023-12-25T03:38:01 Z Minbaev Team Contest (JOI22_team) C++17
0 / 100
2000 ms 24016 KB
#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 c1,int c2,int v,int tl,int tr){
	
	if(t[v].s.f>=val1||t[v].s.s>=val2||tr<tl||t[v].f<=c1||t[v].f<=c2){
		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&&t[v*2+1].f>c1&&t[v*2+1].f>c2){
		return get(val1,val2,c1,c2,v*2+1,tm+1,tr);
	}
	else return get(val1,val2,c1,c2,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],c1[i-1].f,c1[j-1].f,1,1,n);
				if(h!=0){
					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();

}

Compilation message

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
1 Correct 3 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 4 ms 6784 KB Output is correct
15 Incorrect 2 ms 6748 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 4 ms 6784 KB Output is correct
15 Incorrect 2 ms 6748 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Execution timed out 2035 ms 24016 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Execution timed out 2035 ms 24016 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Execution timed out 2035 ms 24016 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Execution timed out 2035 ms 24016 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 4 ms 6784 KB Output is correct
15 Incorrect 2 ms 6748 KB Output isn't correct
16 Halted 0 ms 0 KB -