# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010636 | tarpent | Trading (IZhO13_trading) | C++14 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<<' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |