Submission #1259141

#TimeUsernameProblemLanguageResultExecution timeMemory
1259141antonnNew Home (APIO18_new_home)C++20
5 / 100
5095 ms5476 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 3e5 + 7;

int n, k, q;
int x[N], t[N], a[N], b[N], l[N], y[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> t[i] >> a[i] >> b[i];
    }
    for (int i = 1; i <= q; ++i) {
        int l, y;
        cin >> l >> y;
        vector<int> closest(k + 1, 1e9);
        for (int j = 1; j <= n; j++) {
            if (a[j] <= y && y <= b[j]) {
                closest[t[j]] = min(closest[t[j]], abs(l - x[j]));
            }
        }
        int ans = -1;
        for (int j = 1; j <= k; j++) {
            if (closest[j] == 1e9) {
                ans = -1;
                break;
            } else {
                ans = max(ans, closest[j]);
            }
        }
        cout << ans << "\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...