Submission #983059

#TimeUsernameProblemLanguageResultExecution timeMemory
983059vjudge1New Home (APIO18_new_home)C++17
5 / 100
5101 ms36356 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int n, k, q, i, l, y, cur, ans, x[300001], t[300001], a[300001], b[300001]; vector<pair<int, pair<int, int>>> g[300001]; signed main() { cin.tie(0)->sync_with_stdio(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif cin >> n >> k >> q; for (i = 1; i <= n; i++) { cin >> x[i] >> t[i] >> a[i] >> b[i]; g[t[i]].push_back({x[i], {a[i], b[i]}}); } while (q--) { cin >> l >> y; ans = 0; for (i = 1; i <= k; i++) { cur = 1e18; for (auto j : g[i]) { if (j.second.first <= y && y <= j.second.second) { cur = min(cur, abs(l - j.first)); } } if (cur >= 1e17) { ans = -1; break; } ans = max(ans, cur); } cout << ans << "\n"; } }
#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...