# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378456 | ijxjdjd | Trading (IZhO13_trading) | C++14 | 381 ms | 35548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |