# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966052 | blackslex | Trading (IZhO13_trading) | C++17 | 184 ms | 24880 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;
using pii = pair<int, int>;
int n, m, x, y, z;
int main() {
scanf("%d %d", &n, &m);
vector<vector<pii>> oper(n + 5, vector<pii>());
for (int i = 1; i <= m; i++) scanf("%d %d %d", &x, &y, &z), oper[x].emplace_back(z - x, i), oper[y + 1].emplace_back(0, i);
priority_queue<pii> pq;
vector<bool> cadd(m + 5);
for (int i = 1; i <= n; i++) {
for (auto &[x, y]: oper[i]) {
if (!cadd[y]) pq.emplace(x, y);
cadd[y] = !cadd[y];
}
while (!pq.empty() && !cadd[pq.top().second]) pq.pop();
printf("%d ", pq.empty() ? 0 : pq.top().first + i);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |