제출 #1220142

#제출 시각아이디문제언어결과실행 시간메모리
1220142emptypringlescanTwo Antennas (JOI19_antennas)C++17
2 / 100
3092 ms3140 KiB
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	pair<long long,pair<int,int> > arr[n+1];
	for(int i=1; i<=n; i++) cin >> arr[i].first >> arr[i].second.first >> arr[i].second.second;
	int q;
	cin >> q;
	while(q--){
		int a,b;
		cin >> a >> b;
		long long ans=-1;
		for(int i=a; i<=b; i++){
			for(int j=i+1; j<=b; j++){
				int dif=j-i;
				if(arr[i].second.first<=dif&&dif<=arr[i].second.second&&arr[j].second.first<=dif&&dif<=arr[j].second.second){
					ans=max(ans,abs(arr[i].first-arr[j].first));
				}
			}
		}
		cout << ans << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...