# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47576 | fallingstar | Trading (IZhO13_trading) | C++17 | 685 ms | 31244 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 <vector>
#include <set>
using namespace std;
const int N = 3e5 + 2;
int n, m;
vector<pair<int, int> > begpoint[N], endpoint[N];
int main()
{
cin >> n >> m;
for (int i = 0; i < m; ++i)
{
int l, r, x;
cin >> l >> r >> x;
begpoint[l].push_back({x - l, i});
endpoint[r].push_back({x - l, i});
}
set<pair<int, int> > s;
for (int i = 1; i <= n; ++i)
{
for (auto p: begpoint[i]) s.insert(p);
if (!s.empty())
cout << i + prev(s.end())->first << ' ';
else
cout << 0 << ' ';
for (auto p: endpoint[i]) s.erase(p);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |