Submission #638881

#TimeUsernameProblemLanguageResultExecution timeMemory
638881MohamedAhmed04Trading (IZhO13_trading)C++14
100 / 100
263 ms28984 KiB
#include <bits/stdc++.h> using namespace std ; const int MAX = 3e5 + 10 ; int arr[MAX] ; int n , m ; vector< pair<int , int> >vp[MAX] ; int ans[MAX] ; int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n>>m ; for(int i = 0 ; i < m ; ++i) { int l , r , x ; cin>>l>>r>>x ; vp[l].emplace_back(x-l , 1) , vp[r+1].emplace_back(x-l , -1) ; } multiset<int>s ; for(int i = 1 ; i <= n ; ++i) { for(auto &p : vp[i]) { if(p.second == 1) s.insert(p.first) ; else s.erase(s.find(p.first)) ; } if(s.size()) ans[i] = *s.rbegin() + i ; } for(int i = 1 ; i <= n ; ++i) cout<<ans[i]<<" " ; cout<<"\n" ; return 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...