이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define st first
#define nd second
#define test cout<<"test"<<endl;
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
ll INF = 1e9;
ll mod = 1e9+7;
ll n,m,k,l,r,ans;
ll min(ll a, ll b) {
return (a<b)? a:b;
}
ll max(ll a, ll b) {
return a+b-min(a,b);
}
ll q;
int main() {
//freopen("input","r",stdin);
cin>>n;
vector<pair<ll,pll> > ants;
ants.resize(n);
for(int i=0; i<n; i++) {
cin>>ants[i].st>>ants[i].nd.st>>ants[i].nd.nd;
}
cin>>q;
for(int i=0; i<q; i++) {
cin>>l>>r;
l--;
r--;
m = -1;
for(int j=l; j<=r; j++) {
for(int k=j+1; k<=r; k++) {
if(abs(j-k) >= ants[j].nd.st and abs(j-k) <= ants[j].nd.nd and abs(j-k) <= ants[k].nd.nd and abs(j-k) >= ants[k].nd.st) {
m = max(m , abs(ants[j].st - ants[k].st));
}
}
}
cout<<m<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |