# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21225 | jjwdi0 | Trading (IZhO13_trading) | C++11 | 293 ms | 20704 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;
struct Query {
int s, e, v;
Query() {}
Query(int _s, int _e, int _v) { s = _s, e = _e, v = _v; }
bool operator < (const Query &A) const { return v > A.v; }
}T[300005];
int N, Q;
int ans[300005];
set<int> s;
int main() {
scanf("%d %d", &N, &Q);
for(int i=0; i<Q; i++) scanf("%d %d %d", &T[i].s, &T[i].e, &T[i].v), T[i].v -= T[i].s;
sort(T, T+Q);
for(int i=1; i<=N; i++) ans[i] = -i, s.insert(i);
for(int i=0; i<Q; i++) {
auto it1 = s.lower_bound(T[i].s), it2 = s.upper_bound(T[i].e);
for(auto iter = it1; iter != it2; iter++) ans[*iter] = T[i].v;
s.erase(it1, it2);
}
for(int i=1; i<=N; i++) printf("%d ", ans[i] + i);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |