Submission #991190

#TimeUsernameProblemLanguageResultExecution timeMemory
991190tch1cherinTrading (IZhO13_trading)C++17
100 / 100
163 ms39384 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> L(M), R(M), X(M); vector<vector<pair<int, int>>> add(N); for (int i = 0; i < M; i++) { cin >> L[i] >> R[i] >> X[i]; L[i]--; add[L[i]].push_back({X[i] - L[i], R[i]}); } vector<vector<int>> events(N); multiset<int> S; for (int i = 0; i < N; i++) { for (int x : events[i]) { S.erase(S.find(x)); } for (auto [x, r] : add[i]) { S.insert(x); if (r < N) { events[r].push_back(x); } } cout << (S.empty() ? 0 : *S.rbegin() + i) << " \n"[i + 1 == N]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...