제출 #320507

#제출 시각아이디문제언어결과실행 시간메모리
320507sofapudenTrading (IZhO13_trading)C++14
100 / 100
515 ms19648 KiB
#include <bits/stdc++.h>

using namespace std;

int main(){
	int n, m; cin >> n >> m;
	vector<array<int,3>> toAdd, toRem;
	for(int i = 0; i < m; ++i){
		int l, r, x; cin >> l >> r >> x;
		toAdd.push_back({l,r,x-l});
		toRem.push_back({r,l,x-l});
	}
	sort(toAdd.begin(), toAdd.end());
	sort(toRem.begin(), toRem.end());
	int cnl = 0, cnr = 0;
	map<int,int> M;
	for(int i = 1; i <= n; ++i){
		while(toAdd[cnl][0] == i){
			M[toAdd[cnl++][2]]++;
		}
		while(toRem[cnr][0] == i-1){
			M[toRem[cnr][2]]--;
			if(!M[toRem[cnr][2]]){
				M.erase(toRem[cnr][2]);
			}
			cnr++;
		}
		if(M.empty()){
			cout << "0 ";
		}
		else{
			cout << prev(M.end())->first + i << " ";
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...