제출 #307580

#제출 시각아이디문제언어결과실행 시간메모리
307580kaplanbar거래 (IZhO13_trading)C++14
100 / 100
607 ms65536 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int N = 3e5+5; int n, q; multiset<int> add[N], rem[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q; for(int i = 0; i < q; i++) { int l, r, x; cin >> l >> r >> x; l--; r--; add[l].insert(x - l); rem[r + 1].insert(x - l); } multiset<int> cur; for(int i = 0; i < n; i++) { for(int x : rem[i]) { cur.erase(cur.find(-x)); } for(int x : add[i]) { cur.insert(-x); } int now = 0; if(cur.size()) now = -(*cur.begin()) + i; cout << now << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...