# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
763581 | Blagoj | Trading (IZhO13_trading) | C++17 | 213 ms | 27640 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>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<pair<int, int>> v[n + 2];
for (int i = 0; i < m; i++) {
int l, r, x;
cin >> l >> r >> x;
v[l].push_back({0, x - l});
v[r + 1].push_back({1, x - l});
}
multiset<int> s;
for (int i = 1; i <= n; i++) {
for (auto x : v[i]) {
if (x.first == 0) s.insert(x.second);
else s.erase(s.find(x.second));
}
if (!s.size()) cout << 0 << " ";
else cout << *s.rbegin() + i << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |