# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1066990 | vjudge1 | Trading (IZhO13_trading) | C++17 | 7 ms | 14684 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>
using namespace std;
#define int long long
#define For(i, a, b) for (int i = a; i <= b; ++i)
#define RFor(i, a, b) for (int i = a; i >= b; --i)
#define get_bit(bit, mask) (((mask) >> (bit)) & 1)
#define set_bit(bit, mask) ((mask) | (1ll << (bit)))
#define off_bit(bit, mask) ((mask) & (~(1ll << (bit))))
#define cnt_bit(mask) __builtin_popcountll(mask)
#define top_bit(mask) (63 - __builtin_clzll(mask))
#define log(a) cout << #a << " = " << a << '\n'
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
const int N = 3e5 + 5;
const int INF = 1e18;
int ans[N];
int n, m;
int l[N], r[N], x[N];
vector<int> start[N], stop[N];
void GetInput() {
cin >> n >> m;
For(i, 1, n) cin >> l[i] >> r[i] >> x[i];
}
void Rep() {
For(i, 1, n) cout << ans[i] << ' ';
}
void Solve() {
For(i, 1, n)
start[l[i]].push_back(x[i] - l[i]),
stop[r[i]].push_back(x[i] - l[i]);
multiset<int> mts;
mts.insert(-INF);
For(i, 1, n) {
for (int e : start[i]) mts.insert(e);
ans[i] = max(0ll, *mts.rbegin() + i);
for (int e : stop[i]) mts.erase(mts.find(e));
}
}
signed main() {
#ifndef LOCAL
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
GetInput();
Solve();
Rep();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |