제출 #1010651

#제출 시각아이디문제언어결과실행 시간메모리
1010651tarpent거래 (IZhO13_trading)C++14
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 3000007; #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; if(val[a].first==0) val[a]={b,c}; else{ while(true){ if(val[a].first!=0){ if(val[a].second<c){ int tr = val[a].first; int tpc = val[a].second; val[a] = {b,c}; a=b+1; b=tr; c=tpc; } else{ if(val[a].first<b){ c+=val[a].first+1-1; a=val[a].first+1; } else break; } } else{ val[a]={b,c}; break; } } } } 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(!vre.empty() and val[vre.top().second].first<i){ 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...