Submission #336570

#TimeUsernameProblemLanguageResultExecution timeMemory
336570nickmet2004Trading (IZhO13_trading)C++11
100 / 100
375 ms31072 KiB
#include<bits/stdc++.h> using namespace std; const int N = 3e5 +5; int n , m , ans[N] , oo = -2e9; vector<int> L[N], R[N]; int main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= m; ++i){ int l , r , c; cin >> l >> r >> c; L[l].emplace_back(c - l); R[r].emplace_back(c - l); } multiset<int> s; s.insert(oo); for(int i = 1; i <= n; ++i){ for(int x : L[i])s.insert(x); int y = *s.rbegin(); if(y == oo) ans[i] = 0; else ans[i] = i + y; for(int x : R[i])s.erase(s.find(x)); } for(int i = 1; i<= n; ++i) cout << ans[i] << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...