104482024-04-02 19:52:16999Szakaszokcpp17Time limit exceeded 79/100156ms37828 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using orderedset = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int m,n;cin>>m>>n;
	orderedset s;
	vector<vector<int>> h(m,vector<int>(3)),v(n,vector<int>(3)),will(0,vector<int>(3));
	for(int i = 0; i<m;i++){
		cin>>h[i][0]>>h[i][1]>>h[i][2];
		will.push_back({h[i][0],0,h[i][2]});
		will.push_back({h[i][1],-1,h[i][2]});
	}
	for(int i = 0; i<n;i++){
		cin>>v[i][2]>>v[i][0]>>v[i][1];
		will.push_back({v[i][2],-2,i});
	}
	sort(will.begin(),will.end());
	int ans=-1,ansv=0;
	int w=will.size();
	for(int i = 0;i<w;i++){
		if(will[i][1]==0){
			s.insert(will[i][2]);
		}
		else if(will[i][1]==-1){
			s.erase(will[i][2]);
		}
		else{
			int temp=s.order_of_key(v[will[i][2]][1]+1)-s.order_of_key(v[will[i][2]][0]);
			if(temp>ansv){
				ansv=temp;
				ans=will[i][2]+1;
			}
		}
	}cout<<ans<<endl;
}
SubtaskSumTestVerdictTimeMemory
base79/100
1Accepted0/03ms1952 KiB
2Accepted0/027ms8048 KiB
3Accepted2/23ms2564 KiB
4Accepted2/24ms3268 KiB
5Accepted2/26ms3664 KiB
6Accepted3/314ms5604 KiB
7Accepted3/39ms5648 KiB
8Accepted3/318ms7408 KiB
9Accepted3/319ms8120 KiB
10Accepted4/420ms8484 KiB
11Accepted4/427ms9432 KiB
12Accepted4/446ms13432 KiB
13Accepted7/745ms13860 KiB
14Accepted7/754ms16344 KiB
15Accepted7/763ms20584 KiB
16Time limit exceeded0/7155ms35400 KiB
17Accepted7/743ms13864 KiB
18Accepted7/763ms20864 KiB
19Accepted7/7118ms27636 KiB
20Time limit exceeded0/7156ms19092 KiB
21Time limit exceeded0/7153ms35548 KiB
22Accepted7/7118ms37828 KiB