Submission #860149

#TimeUsernameProblemLanguageResultExecution timeMemory
860149aykhnTrading (IZhO13_trading)C++14
100 / 100
367 ms65536 KiB
#include <bits/stdc++.h> // author : aykhn using namespace std; typedef long long ll; #define pb push_back #define ins insert #define mpr make_pair #define all(v) v.begin(), v.end() #define bpc __builtin_popcount #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define int ll #define infll 0x3F3F3F3F3F3F3F3F #define inf 0x3F3F3F3F signed main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int n, m; cin >> n >> m; vector<multiset<int>> v1(n + 1); vector<multiset<int>> v2(n + 2); while (m--) { int l, r, x; cin >> l >> r >> x; v1[l].ins(x - l); v2[r + 1].ins(x - l); } multiset<int> ms; for (int i = 1; i <= n; i++) { for (int x : v2[i]) ms.erase(ms.lower_bound(x)); for (int x : v1[i]) ms.ins(x); if (!ms.empty()) { cout << *ms.rbegin() + i << " "; } else { cout << 0 << " "; } } cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...