# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964691 | pcc | Trading (IZhO13_trading) | C++17 | 197 ms | 29676 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 ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 3e5+10;
ll N,M;
vector<pii> op[mxn];
multiset<int> st;
int ans[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 0;i<M;i++){
int a,b,c;
cin>>a>>b>>c;
op[a].push_back(pii(c-a,1));
op[b+1].push_back(pii(c-a,-1));
}
for(int i = 1;i<=N;i++){
for(auto &j:op[i]){
if(j.sc>0)st.insert(j.fs);
else st.erase(st.find(j.fs));
}
if(st.empty())ans[i] = 0;
else ans[i] = *st.rbegin()+i;
}
for(int i = 1;i<=N;i++)cout<<ans[i]<<' ';cout<<'\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |