Submission #867472

#TimeUsernameProblemLanguageResultExecution timeMemory
867472sleepntsheepTrading (IZhO13_trading)C++17
100 / 100
120 ms6600 KiB
#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 timeMemoryGrader output
Fetching results...