# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
755617 | gvancak | Trading (IZhO13_trading) | C++17 | 330 ms | 30888 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 s second
#define f first
using namespace std;
ll n,a[300005],sum,x,k,ans,t,ans1,y,z,u,m;
bool ok;
vector <ll> l[300005],r[300005];
multiset <ll> s;
int main(){
ios :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n>>m;
for (int o=1; o<=m; o++){
cin>>y>>z>>x;
l[y].push_back(x-y+1);
r[z].push_back(x-y+1);
}
for (int i=1; i<=n; i++){
for (int j=0; j<l[i].size(); j++){
s.insert(l[i][j]);
}
if (s.size()==0) {
cout<<0<<" ";
continue;
}
set <ll> ::iterator it = s.end();
it--;
cout<<(*it)+i-1<<" ";
for (int j=0; j<r[i].size(); j++){
s.erase(s.find(r[i][j]));
}
}
cout<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |