Submission #882268

#TimeUsernameProblemLanguageResultExecution timeMemory
882268alexddTrading (IZhO13_trading)C++17
100 / 100
405 ms38460 KiB
#include<iostream> #include<vector> #include<set> using namespace std; int n,m; vector<pair<int,int>> inc[300005]; vector<pair<int,int>> sf[300005]; signed main() { cin>>n>>m; int l,r,a; for(int i=1;i<=m;i++) { cin>>l>>r>>a; inc[l].push_back({a,r}); sf[r].push_back({a,l}); } set<pair<int,pair<int,int>>> s; for(int i=1;i<=n;i++) { for(auto x:inc[i]) { s.insert({x.first - i, x}); } if(s.empty()) { cout<<0<<" "; } else { auto it = s.rbegin(); pair<int,pair<int,int>> cop = *it; cout<<cop.first + i<<" "; } for(auto x:sf[i]) { s.erase({x.first - x.second, {x.first,i}}); } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...