제출 #991190

#제출 시각아이디문제언어결과실행 시간메모리
991190tch1cherin거래 (IZhO13_trading)C++17
100 / 100
163 ms39384 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> L(M), R(M), X(M); vector<vector<pair<int, int>>> add(N); for (int i = 0; i < M; i++) { cin >> L[i] >> R[i] >> X[i]; L[i]--; add[L[i]].push_back({X[i] - L[i], R[i]}); } vector<vector<int>> events(N); multiset<int> S; for (int i = 0; i < N; i++) { for (int x : events[i]) { S.erase(S.find(x)); } for (auto [x, r] : add[i]) { S.insert(x); if (r < N) { events[r].push_back(x); } } cout << (S.empty() ? 0 : *S.rbegin() + i) << " \n"[i + 1 == N]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...