# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249739 | srvlt | Trading (IZhO13_trading) | C++14 | 309 ms | 28384 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int n0 = 3e5 + 123;
int n, m;
vector <array <int, 2> > q[n0];
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n >> m;
for (int i = 0; i < m; i++) {
int l, r, x;
cin >> l >> r >> x;
q[l].pb({0, x - l}), q[r + 1].pb({1, x - l});
}
multiset <int> st;
for (int i = 1; i <= n; i++) {
sort(all(q[i]));
for (auto j : q[i]) {
if (j[0] == 0) st.insert(j[1]);
else st.erase(st.find(j[1]));
}
if (st.empty()) cout << 0 << ' ';
else cout << *(--st.end()) + i << ' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |