# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867472 | sleepntsheep | Trading (IZhO13_trading) | C++17 | 120 ms | 6600 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 <queue>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 200005
int n, m, j;
vector<tuple<int, int, int>> v;
priority_queue<pair<int, int>> q;
int main()
{
ShinLena;
cin >> n >> m;
v.resize(m);
for (auto &[l, r, x] : v) cin >> l >> r >> x;
sort(ALL(v));
for (int f, i = 1; i <= n; ++i)
{
for (; get<0>(v[j]) == i; q.emplace(get<2>(v[j]) - get<0>(v[j]), get<1>(v[j])), ++j);
for (f = 0; q.size() && !f; )
{
auto [z, r] = q.top();
if (r >= i) { cout << i + z << ' '; f=1; }
else q.pop();
}
if (!f) cout << "0 ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |