# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
351272 | nicolaalexandra | Trading (IZhO13_trading) | C++14 | 556 ms | 22848 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 DIM 300010
using namespace std;
struct eventt{
int poz,tip,idx;
};
vector <eventt> events;
multiset <int> s;
struct idk{
int x,y,val;
} v[DIM];
inline int cmp (eventt a, eventt b){
return a.poz < b.poz;
}
int n,m,i,x,y,val;
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n>>m;
for (i=1;i<=m;i++){
cin>>x>>y>>val;
events.push_back({x,1,i});
events.push_back({y+1,-1,i});
v[i] = {x,y,val};
}
sort (events.begin(),events.end(),cmp);
int pos = 0;
for (i=1;i<=n;i++){
while (pos < events.size() && events[pos].poz == i){
int idx = events[pos].idx;
if (events[pos].tip == 1)
s.insert(v[idx].val - v[idx].x);
else s.erase(s.find(v[idx].val - v[idx].x));
pos++;
}
if (s.empty())
cout<<0<<" ";
else cout<<i + *s.rbegin()<<" ";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |