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 pb push_back
#define mp make_pair
#define int long long
#define itr ::iterator itr
typedef pair<int,int> pii;
const int MAX=1e5;
const int INF=1e12;
int N,K,Q,res,loc,year,X[MAX],T[MAX],S[MAX],E[MAX],dp[MAX];
signed main()
{
ios_base::sync_with_stdio(false);
/*cin.tie(0);
cout.tie(0);*/
cin>>N>>K>>Q;
for(int A=1;A<=N;A++)
cin>>X[A]>>T[A]>>S[A]>>E[A];
while(Q--)
{
res=0;
cin>>loc>>year;
for(int A=1;A<=K;A++)
dp[A]=INF;
for(int A=1;A<=N;A++)
{
if(S[A]<=year and E[A]>=year)
dp[T[A]]=min(dp[T[A]],abs(X[A]-loc));
}
for(int A=1;A<=K;A++)
res=max(res,dp[A]);
if(res==INF)
res=-1;
cout<<res<<"\n";
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |