# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037062 | vjudge1 | Trading (IZhO13_trading) | C++17 | 172 ms | 60220 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 top_bit(mask) (31 - __builtin_clz(mask))
#define log(a) cout << #a << " = " << a << '\n'
#define ii pair<int, int>
#define iii tuple<int, int, int>
const int N = 5e5 + 5;
int ans[N];
int n, m;
int l[N], r[N], x[N];
void GetInput() {
cin >> n >> m;
For(i, 1, m) cin >> l[i] >> r[i] >> x[i];
}
void Rep() {
For(i, 1, n) cout << ans[i] << ' ';
}
vector<int> add[N], trash[N];
void Solve() {
For(i, 1, m)
add[l[i]].push_back(l[i] - x[i]),
trash[r[i]].push_back(l[i] - x[i]);
multiset<int> mts;
For(i, 1, n) {
int lans = 0;
for (int item : add[i]) mts.insert(item);
if (mts.size()) lans = i - *mts.begin();
ans[i] = lans;
for (int item : trash[i]) mts.erase(mts.find(item));
}
}
signed main() {
#ifndef LOCAL
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
// int t; cin >> t;
// while (t--)
GetInput(),
Solve(),
Rep();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |