Submission #380347

#TimeUsernameProblemLanguageResultExecution timeMemory
380347ritul_kr_singhTrading (IZhO13_trading)C++17
100 / 100
443 ms35284 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << ' ' << #define nl << '\n' signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; int a[m], ans[n]; vector<int> starts[n], ends[n]; for(int i=0, l, r; i<m; ++i){ cin >> l >> r >> a[i]; starts[l-1].push_back(i); ends[r-1].push_back(i); a[i] -= l-1; } multiset<int> s; for(int i=0; i<n; ++i){ for(int j : starts[i]) s.insert(a[j]); ans[i] = s.empty() ? 0LL : *s.rbegin() + i; for(int j : ends[i]) s.erase(s.find(a[j])); } for(int i : ans) cout << i << ' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...