# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47527 | aome | Trading (IZhO13_trading) | C++17 | 457 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;
const int N = 300005;
int n, m;
int res[N];
int l[N], r[N], x[N];
set< pair<int, int> > s;
vector<int> vec[N];
int main() {
ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
cin >> l[i] >> r[i] >> x[i];
vec[l[i]].push_back(i);
vec[r[i] + 1].push_back(-i);
}
for (int i = 1; i <= n; ++i) {
for (auto j : vec[i]) {
if (j > 0) s.insert({x[j] - l[j], j});
else s.erase({x[-j] - l[-j], -j});
}
if (s.size()) res[i] = (--s.end()) -> first + i;
cout << res[i] << ' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |