# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307580 | kaplanbar | Trading (IZhO13_trading) | C++14 | 607 ms | 65536 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 ll = long long;
constexpr int N = 3e5+5;
int n, q;
multiset<int> add[N], rem[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
for(int i = 0; i < q; i++) {
int l, r, x;
cin >> l >> r >> x;
l--;
r--;
add[l].insert(x - l);
rem[r + 1].insert(x - l);
}
multiset<int> cur;
for(int i = 0; i < n; i++) {
for(int x : rem[i]) {
cur.erase(cur.find(-x));
}
for(int x : add[i]) {
cur.insert(-x);
}
int now = 0;
if(cur.size()) now = -(*cur.begin()) + i;
cout << now << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |