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 pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int inf = 1e9;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k, q; cin >> n >> k >> q;
vector<vector<tuple<int, int, int>>> stores(k);
for(int i = 0; i < n; i++){
int x, t, a, b; cin >> x >> t >> a >> b; t--;
stores[t].push_back({x, a, b});
}
while(q--){
int l, y; cin >> l >> y;
int ans = 0;
for(auto s: stores){
int mn = inf;
for(auto [x, a, b]: s) if(a <= y && b >= y) mn = min(mn, abs(l-x));
if(mn == inf){
ans = -1;
break;
}
ans = max(ans, mn);
}
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... |