# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4777 | gs13068 | Trading (IZhO13_trading) | C++98 | 396 ms | 22756 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<cstdio>
#include<vector>
#include<set>
struct hat
{
bool type;
int x;
} h;
std::vector<hat> d[300001];
std::multiset<int> s;
std::multiset<int>::iterator it;
int main()
{
int a,b,c;
int i,j,n,m;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++)
{
scanf("%d%d%d",&a,&b,&c);
h.x=c-a;
h.type=false;
d[a].push_back(h);
h.type=true;
d[b+1].push_back(h);
}
for(i=1;i<=n;i++)
{
for(j=0;j<d[i].size();j++)
{
if(d[i][j].type)
s.erase(s.find(d[i][j].x));
else
s.insert(d[i][j].x);
}
if(s.empty())printf("0 ");
else
{
it=s.end();
it--;
printf("%d ",*it+i);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |