# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895756 | heeheeheehaaw | Trading (IZhO13_trading) | C++17 | 2 ms | 8540 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>
using namespace std;
int val[300005];
vector<int> v[300005];
bool visited[300005];
int main()
{
int n, m;
cin>>n>>m;
for(int i = 1; i <= m; i++)
{
int st, dr, x;
cin>>st>>dr>>x;
val[i] = x;
v[st].push_back(i);
v[dr + 1].push_back(-i);
}
deque<pair<int, int>> dq;
for(int i = 1; i <= n; i++)
{
for(auto it : v[i])
{
if(it > 0)
{
int nr = val[it] - i + 1;
while(!dq.empty() && dq.back().first <= nr)
dq.pop_back();
dq.push_back({nr, it});
}
else visited[-it] = true;
}
while(!dq.empty() && visited[dq.front().second])
dq.pop_front();
if(dq.empty()) cout<<0<<" ";
else cout<<dq.front().first + i - 1<<" ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |