Submission #867466

#TimeUsernameProblemLanguageResultExecution timeMemory
867466Vladth11Trading (IZhO13_trading)C++14
100 / 100
258 ms31172 KiB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast")

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

const ll NMAX = 300002;
const ll INF = (1LL << 60);
const ll nrbits = 20;
const ll MOD = 998244353;
const ll bucket = 320;
const double eps = 0.00000001;

struct ura{
    int l, r, x, bgt;
}qq[NMAX];

multiset <int> st;
vector <int> events[NMAX];


signed main() {
#ifdef HOME
    ifstream cin(".in");
    ofstream cout(".out");
#endif // HOME
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, i;
    cin >> n >> m;
    for(i = 1; i <= m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        qq[i] = {a, b, c};
        events[a].push_back(i);
        events[b + 1].push_back(-i);
    }
    int offset = 0;
    for(i = 1; i <= n; i++){
        offset++;
        for(auto x : events[i]){
            if(x < 0){
                st.erase(st.find(qq[-x].bgt));
            }else{
                st.insert(qq[x].x - offset);
                qq[x].bgt = qq[x].x - offset;
            }
        }
        if(st.size() == 0){
            cout << 0 << " ";
            continue;
        }
        auto it = prev(st.end());
        cout << (*it) + offset << " ";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...