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>
#define vi vector<int>
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<long long int, long long int>>
#define pb push_back
#define f0r(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef long long int ll;
int main(){
int n,k,q;
cin>>n>>k>>q;
vector<vector<ll>>v[k];
f0r(i,n){
ll x,t,a,b;
cin>>x>>t>>a>>b;
v[--t].pb({x,a,b});
}
while(q--){
ll loc, time;
cin>>loc>>time;
ll inc = 0;
f0r(i,k){
ll mn = 4e18;
for(auto u : v[i]){
//cout<<u[2]<<' '<<u[1]<<'\n';
if(time <= u[2] && time >= u[1])mn = min(mn, abs(loc - u[0]));
}
//cout<<mn<<'\n';
if(mn == 4e18){
inc = -1;
break;
}
else inc = max(inc, mn);
}
cout<<inc<<'\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... |