# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946613 | Zena_Hossam | Trading (IZhO13_trading) | C++14 | 185 ms | 33156 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;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double
#define ll long long
//#define ll1 int
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
int main()
{
//freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout);
ll T=1;
fi
//cin>>T;ll oo=0;
while(T--)
{
ll n,m;
cin>>n>>m;
ll a[m+5]= {},b[m+5]= {},c[m+5]={};
vector<pair<ll,ll>>s[n+5],v[n+5];
for(ll i=0; i<m; i++)
{
ll x,b1,c1;
cin>>x>>b1>>c1;a[i]=x,b[i]=b1,c[i]=c1;
s[x].push_back({c1,i});
}priority_queue<pair<ll,ll>>q;q.push({-1e18,0});
for(ll i=1; i<=n; i++)
{
for(ll j=0;j<s[i].sz;j++){
q.push({s[i][j].first-i-1,s[i][j].second});
}
while(q.size()>1){//cout<<q.size()<<" "<<b[q.top().second]<<"\n";
if(b[q.top().second]>=i)
break;
q.pop();
}
if(q.top().first==-1e18)cout<<0<<" ";
else
cout<<q.top().first+i+1<<" ";
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |