Submission #969877

#TimeUsernameProblemLanguageResultExecution timeMemory
969877VMaksimoski008Trading (IZhO13_trading)C++17
100 / 100
360 ms29328 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, q, l, r, k; cin >> n >> q; vector<int> L[n+1], R[n+1]; for(int i=0; i<q; i++) { cin >> l >> r >> k; L[l].push_back(k - l); R[r].push_back(k - l); } multiset<int> ms; for(int i=1; i<=n; i++) { for(int &x : L[i]) ms.insert(x); if(ms.empty()) cout << 0 << " "; else cout << i + *ms.rbegin() << " "; for(int &x : R[i]) ms.erase(ms.find(x)); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...