#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 3e5 + 5;
int a[maxn], n, m;
vector<int> them[maxn], xoa[maxn];
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
multiset<int> st;
for(int i = 1; i <= m; i++) {
int l, r, x; cin >> l >> r >> x;
them[l].push_back(x - l);
xoa[r + 1].push_back(x - l);
}
for(int i = 1; i <= n; i++) {
for(auto j : them[i]) {
st.insert(j);
}
for(auto j : xoa[i]) {
st.erase(st.find(j));
}
if(st.size() == 0) {
cout << 0 << ' ';
}
else cout << *st.rbegin() + i << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |