Submission #1116264

#TimeUsernameProblemLanguageResultExecution timeMemory
1116264Tsagana거래 (IZhO13_trading)C++14
100 / 100
215 ms36656 KiB
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
 
using namespace std;
 
multiset<int> s;
vector<int> a[300001];
vector<int> b[300001];
 
void solve () {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int l, r, k; cin >> l >> r >> k;
		int x = l - k;
		a[l].pb(x);
		b[r].pb(x);
	}
 
	for (int i = 1; i <= n; i++) {
		for (auto x: a[i]) s.insert(x);
 
		cout << (s.empty() ? 0 : i - *s.begin()) << ' ';
 
		for (auto x: b[i]) {
			auto y = s.find(x);
			if(y == s.end()) continue;
			s.erase(y);
		}
	}
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...