Submission #763581

#TimeUsernameProblemLanguageResultExecution timeMemory
763581BlagojTrading (IZhO13_trading)C++17
100 / 100
213 ms27640 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") using namespace std; #define endl '\n' #define ll long long #define all(x) x.begin(), x.end() int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<pair<int, int>> v[n + 2]; for (int i = 0; i < m; i++) { int l, r, x; cin >> l >> r >> x; v[l].push_back({0, x - l}); v[r + 1].push_back({1, x - l}); } multiset<int> s; for (int i = 1; i <= n; i++) { for (auto x : v[i]) { if (x.first == 0) s.insert(x.second); else s.erase(s.find(x.second)); } if (!s.size()) cout << 0 << " "; else cout << *s.rbegin() + i << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...