제출 #342783

#제출 시각아이디문제언어결과실행 시간메모리
342783Gurban거래 (IZhO13_trading)C++17
100 / 100
379 ms35468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn=3e5+5; int n,m,l,r,x; multiset<int>s; vector<int>L[maxn],R[maxn]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 1;i <= m;i++){ cin >> l >> r >> x; L[l].push_back(x-l); R[r].push_back(x-l); } for(int i = 1;i <= n;i++){ for(auto j : L[i]) s.insert(j); int nw = 0; if(!s.empty()) nw = *s.rbegin() + i; cout<<nw<<' ' ; for(auto j : R[i]) s.erase(s.find(j)); } }
#Verdict Execution timeMemoryGrader output
Fetching results...