Submission #1003576

#TimeUsernameProblemLanguageResultExecution timeMemory
1003576ThegeekKnight16Autobahn (COI21_autobahn)C++17
100 / 100
721 ms94668 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, K, X; cin >> N >> K >> X; vector<tuple<int, int, int>> sweep; set<int> vals; for (int i = 0; i < N; i++) { int L, T, R; cin >> L >> T >> R; T = min(L+T-1, R); sweep.emplace_back(L, 0, -1); vals.insert(L); sweep.emplace_back(T+1, 1, -1); vals.insert(T+1); sweep.emplace_back(R+1, 2, -1); vals.insert(R+1); sweep.emplace_back(T, 4, 3*i); sweep.emplace_back(T+X, 5, 3*i); vals.insert(T); vals.insert(T+X); sweep.emplace_back(R-X, 4, 3*i + 1); sweep.emplace_back(R, 5, 3*i + 1); vals.insert(R-X); vals.insert(R); sweep.emplace_back(L-1, 4, 3*i + 2); sweep.emplace_back(L+X-1, 5, 3*i + 2); vals.insert(L-1); vals.insert(L+X-1); } for (auto x : vals) sweep.emplace_back(x, 3, -1); vector<int> possResp(3*N); sort(sweep.begin(), sweep.end()); int totPeople = 0, totPaying = 0, totPay = 0, lastX = 0, resp = 0; for (auto [x, type, id] : sweep) { // cerr << "x: " << x << ", totPeople: " << totPeople << ", totPaying: " << totPaying << ", totPay: " << totPay << '\n'; if (type == 0) totPeople++; else if (type == 1) totPaying++; else if (type == 2) totPeople--, totPaying--; else if (type == 3) { totPay += (int)(totPeople >= K) * totPaying * (x - lastX); lastX = x; } else if (type == 4) possResp[id] = totPay; else resp = max(resp, totPay - possResp[id]); } cout << resp << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...