Submission #1280367

#TimeUsernameProblemLanguageResultExecution timeMemory
1280367bananade거래 (IZhO13_trading)C++20
100 / 100
126 ms16144 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m;
vector<pair<pair<int, int>, int>> v;
int maxi[300005];
priority_queue<pair<int, int>> pq;

signed main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		v.push_back({{a, b}, c - a});
	}
	sort(v.begin(), v.end());
	int ind = 0;
	for(int i = 1; i <= n; i++) {
		while(ind < v.size()) {
			if(v[ind].first.first <= i) {
				pq.push({v[ind].second, v[ind].first.second});
				ind++;
			} else {
				break;
			}
		}
		while(!pq.empty()) {
			if(pq.top().second < i) {
				pq.pop();
			} else {
				break;
			}
		}
		if(!pq.empty()) {
			maxi[i] = pq.top().first + i;
		}
		cout << maxi[i] << " ";
	}
	cout << "\n";
	
}
#Verdict Execution timeMemoryGrader output
Fetching results...