Submission #260881

#TimeUsernameProblemLanguageResultExecution timeMemory
260881SorahISANew Home (APIO18_new_home)C++17
5 / 100
5047 ms13472 KiB
#pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define double long double using pii = pair<int, int>; template<typename T> using prior = priority_queue<T, vector<T>, greater<T>>; template<typename T> using Prior = priority_queue<T>; #define X first #define Y second #define ALL(x) (x).begin(), (x).end() #define eb emplace_back #define pb push_back #define fastIO() ios_base::sync_with_stdio(false), cin.tie(0) const int INF = 0x7f7f7f7f; const int maxn = 3E5 + 5; struct Store { int x, t, a, b, id; }; int32_t main() { fastIO(); int n, k, q; cin >> n >> k >> q; vector<Store> store(n); for (int i = 0; i < n; ++i) { cin >> store[i].x >> store[i].t >> store[i].a >> store[i].b; --store[i].t, store[i].id = i; } sort(ALL(store), [](auto s1, auto s2) { if (s1.a == s2.a) return s1.b < s2.b; return s1.a < s2.a; }); for (int i = 0; i < q; ++i) { int l, y; vector<int> dis(k, INF); cin >> l >> y; for (int j = 0; j < n; ++j) { if (store[j].a <= y and y <= store[j].b) { dis[store[j].t] = min(dis[store[j].t], abs(l - store[j].x)); } } if (*max_element(ALL(dis)) == INF) cout << -1 << "\n"; else cout << *max_element(ALL(dis)) << "\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...