# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991190 | tch1cherin | Trading (IZhO13_trading) | C++17 | 163 ms | 39384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |