# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168169 | achibasadzishvili | Trading (IZhO13_trading) | C++14 | 470 ms | 55868 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>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
ll n,m,num[500005],L[500005],R[500005];
vector<pair<ll,ll> >v[500005];
vector<ll>er[500005];
multiset<pair<ll,ll> >st;
int main(){
ios::sync_with_stdio(false);
cin >> n >> m;
for(int i=1; i<=m; i++){
ll x;
cin >> L[i] >> R[i] >> x;
num[i] = x;
v[L[i]].pb(mp(x , i));
er[R[i] + 1].pb(i);
}
for(int i=1; i<=n; i++){
for(int j=0; j<v[i].size(); j++)
st.insert(mp(-v[i][j].f - n + i , v[i][j].s));
for(int j=0; j<er[i].size(); j++)
st.erase(st.find(mp(-num[er[i][j]] - n + L[er[i][j]] , er[i][j])));
if(st.size() == 0)cout << "0 ";
else cout << num[(*st.begin()).s] + i - L[(*st.begin()).s] << " ";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |