# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991188 | tch1cherin | Trading (IZhO13_trading) | C++17 | 1 ms | 348 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<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]);
}
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 (int x : add[i]) {
S.insert(x);
}
cout << (S.empty() ? 0 : *S.rbegin() + i) << " \n"[i + 1 == N];
if (R[i] < N) {
events[R[i]].push_back(X[i] - L[i]);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |