Submission #49831

#TimeUsernameProblemLanguageResultExecution timeMemory
49831zetapiNew Home (APIO18_new_home)C++14
5 / 100
5051 ms7036 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...