제출 #47527

#제출 시각아이디문제언어결과실행 시간메모리
47527aome거래 (IZhO13_trading)C++17
100 / 100
457 ms65536 KiB
#include <bits/stdc++.h> using namespace std; const int N = 300005; int n, m; int res[N]; int l[N], r[N], x[N]; set< pair<int, int> > s; vector<int> vec[N]; int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= m; ++i) { cin >> l[i] >> r[i] >> x[i]; vec[l[i]].push_back(i); vec[r[i] + 1].push_back(-i); } for (int i = 1; i <= n; ++i) { for (auto j : vec[i]) { if (j > 0) s.insert({x[j] - l[j], j}); else s.erase({x[-j] - l[-j], -j}); } if (s.size()) res[i] = (--s.end()) -> first + i; cout << res[i] << ' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...