# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249735 | srvlt | Trading (IZhO13_trading) | C++14 | 15 ms | 14848 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 <int> 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(-(x - l)), q[r + 1].pb(x - l);
}
multiset <int> st;
for (int i = 1; i <= n; i++) {
sort(all(q[i]));
for (int j : q[i]) {
if (j < 0) st.insert(-j);
else st.erase(st.find(j));
}
if (st.empty()) cout << 0 << ' ';
else cout << *(--st.end()) + i << ' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |