This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,k,q;
cin>>n>>k>>q;
ll x[n+5],t[n+5],a[n+5],b[n+5];
for(ll i=1;i<=n;i++){
cin>>x[i]>>t[i]>>a[i]>>b[i];
}
ll d[k+5];
while(q--){
ll l,y;
cin>>l>>y;
fill(d+1,d+k+1,1e9);
for(ll i=1;i<=n;i++){
if(a[i]<=y&&y<=b[i]){
d[t[i]]=min(d[t[i]],abs(l-x[i]));
}
}
ll ans=0;
for(ll i=1;i<=k;i++){
ans=max(ans,d[i]);
}
if(ans==1e9) ans=-1;
cout<<ans<<"\n";
}
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |