Submission #1010637

#TimeUsernameProblemLanguageResultExecution timeMemory
1010637tarpentTrading (IZhO13_trading)C++14
0 / 100
1 ms344 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 3e5+7; #define ll long long ll n,m,k,a,b,c; pair<ll,ll> val[maxn]; priority_queue<pair<ll,ll>> vre; int main(){ cin>>n>>m; for(int i = 0; i<m; i++){ cin>>a>>b>>c; val[a]={b,c}; } pair<ll,ll> tre; for(int i = 1; i<n+1; i++){ bool ch = false; if(!vre.empty()){ tre=vre.top(); vre.pop(); vre.push({tre.first+1,tre.second}); } if(val[i].second!=0){ vre.push({val[i].second,i}); } while(val[vre.top().second].first<i && !vre.empty()){ vre.pop(); ch=true; } if(ch && !vre.empty()){ tre=vre.top(); vre.pop(); vre.push({tre.first+(i-tre.second),tre.second}); } if (!vre.empty()) cout<<vre.top().first<<' '; else cout<<0<<' '; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...