Submission #969876

#TimeUsernameProblemLanguageResultExecution timeMemory
969876VMaksimoski008Trading (IZhO13_trading)C++17
100 / 100
402 ms34156 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, q; cin >> n >> q; vector<int> L[n+1], R[n+1]; for(int i=0; i<q; i++) { int l, r, k; 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...