제출 #1161007

#제출 시각아이디문제언어결과실행 시간메모리
1161007crafticatNew Home (APIO18_new_home)C++20
0 / 100
5035 ms45604 KiB
#include <bits/stdc++.h> using namespace std; #define F0R(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = (a); i <= (b); i++) #define ROF(i, a, b) for (ll i = (a); i >= (b); i--) #define REP(i, n) for (ll i = (n); i >= 0; i--) using ll = long long; template<typename T> using V = vector<T>; using vi = vector<ll>; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n, k, q; cin >> n >> k >> q; V<tuple<ll,ll,ll,ll>> updates; // Add time, Type, Pos, TypeX // Ins, Query, Del F0R(i, n) { ll x, t, a, b; cin >> x >> t >> a >> b; updates.emplace_back(a, 1, x, t); updates.emplace_back(b, 3, x, t); } while (q--) { ll l, y; cin >> l >> y; updates.emplace_back(y, 2, l, -1); } sort(updates.begin(), updates.end()); V<multiset<ll>> items(k); for (auto [t, type, pos, posX] : updates) { posX--; if (type == 1) { items[posX].insert(pos); } if (type == 2) { ll ans = 0; F0R(i, k) { ll closest = 1e9; for (auto x : items[i]) { closest = min(closest, abs(x - pos)); } ans = max(ans, closest); } if (ans == 1e9) { cout << -1 << endl; continue; } cout << ans << "\n"; } if (type == 3) { items[posX].erase(items[posX].find(pos)); } } }
#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...