# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053194 | Szymon_Pilipczuk | Trading (IZhO13_trading) | C++17 | 300 ms | 41532 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 <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector <vector <int>> startq(m);
vector <vector <int>> endq(m);
int results[n];
int a,b,c;
for(int i = 0;i<m;i++)
{
cin>>a>>b>>c;
a--;
b--;
startq[i].push_back(a);
startq[i].push_back(b);
startq[i].push_back(c);
endq[i].push_back(b);
endq[i].push_back(a);
endq[i].push_back(c);
}
priority_queue<int> mainq;
priority_queue<int> stopq;
sort(startq.begin(),startq.end());
sort(endq.begin(),endq.end());
startq.push_back(vector<int> {1000000,1000000,0});
endq.push_back(vector<int> {1000000,1000000,0});
int endi = 0;
int starti = 0;
for(int i = 0 ;i<n;i++)
{
while(startq[starti][0]==i)
{
mainq.push(startq[starti][2]-i);
starti++;
}
while(endq[endi][0] == i)
{
stopq.push(endq[endi][2]-endq[endi][1]);
endi++;
}
if (mainq.empty() == true)
{
results[i] = 0;
cout<<0<<" ";
continue;
}
results[i] = mainq.top()+i;
cout<<results[i]<<" ";
if (stopq.empty() == false)
{
while(mainq.top() == stopq.top())
{
mainq.pop();
stopq.pop();
if(stopq.empty() == true)
{
break;
}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |