# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495290 | White | Trading (IZhO13_trading) | C++14 | 478 ms | 30800 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.
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
multiset<long long>a;
vector<long long>L[300001],R[300001];
int main(){
long long n,m,l,r,x;
cin>>n>>m;
for(long long i=0;i<m;i++){
cin>>l>>r>>x;
l--;r--;
L[l].push_back(x-l);
R[r].push_back(x-l);
}
for(long long i=0;i<n;i++){
for(long long j=0;j<L[i].size();j++){
a.insert(L[i][j]);
}
if(a.empty()==true){
cout<<"0 ";
}else{
multiset<long long>::iterator it=a.end();
it--;
cout<<*it+i<<" ";
}
for(long long j=0;j<R[i].size();j++){
a.erase(a.find(R[i][j]));
}
}
cout<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |