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;
const int N = 3e5 + 10;
int n, k, q, a[N][4];
vector<int> store[N];
int main(){
cin >> n >> k >> q;
for (int i = 0; i < n; i ++){
for (int j = 0; j < 4; j ++)
cin >> a[i][j];
store[a[i][1]].push_back(i);
}
for (int i = 0; i < q; i ++){
int l, y;
cin >> l >> y;
int mx = 0;
for (int t = 1; t <= k; t ++){
int mn = 1e9;
for (int x : store[t]){
if (a[x][2] <= y and y <= a[x][3])
mn = min(mn, abs(a[x][0] - l));
}
mx = max(mx, mn);
}
if (mx == 1e9)
cout << -1 << endl;
else
cout << mx << endl;
}
}
# | 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... |