제출 #378456

#제출 시각아이디문제언어결과실행 시간메모리
378456ijxjdjd거래 (IZhO13_trading)C++14
100 / 100
381 ms35548 KiB
#include <bits/stdc++.h> #define FR(i, N) for (int i = 0; i < int(N); i++) #define all(x) begin(x), end(x) using namespace std; using ll = long long; const int MAXN = 300000; multiset<int> mx; int offset = 0; void rm(int p) { mx.erase(mx.find(p-offset)); } void ad(int p) { mx.insert(p-offset); } vector<int> add[MAXN]; vector<int> rem[MAXN]; int main() { cin.tie(0); cin.sync_with_stdio(0); int N, M; cin >> N >> M; FR(i, M) { int L, R, P; cin >> L >> R >> P; add[L].push_back(P); rem[R+1].push_back(P+(R-L) + 1); } for (int i = 1; i <= N; i++) { for (int a : add[i]) { ad(a); } for (int b : rem[i]) { rm(b); } if (mx.size() == 0) { cout << 0 << '\n'; } else { cout << *mx.rbegin() + offset << '\n'; } offset++; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...