# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966632 | vjudge1 | Trading (IZhO13_trading) | C++17 | 133 ms | 14040 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 <iostream>
#include <queue>
#include <algorithm>
using namespace std;
using pii = pair<int, int>;
const int N = 3e5+2;
priority_queue<pii> pq;
struct line{
int l, r, v, w;
bool operator < (const line &o) const {
if (l != o.l) return l < o.l;
return r < o.r;
}
}a[N];
int main()
{
int n, m; scanf("%d %d", &n, &m);
for (int i = 1;i <= m;i++){
int l, r, v; scanf("%d %d %d", &l, &r, &v);
a[i] = {l, r, v, v-l};
}
sort(a+1, a+m+1);
int j = 1;
for (int i = 1;i <= n;i++){
while (a[j].l == i) pq.push({a[j].w, a[j].r}), j++;
while (!pq.empty() && pq.top().second < i) pq.pop();
if (pq.empty()) printf("0 ");
else printf("%d ", pq.top().first+i);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |