# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
874440 | 12345678 | Trading (IZhO13_trading) | C++17 | 143 ms | 25264 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;
const int nx=3e5+5;
int n, m, l, r, x;
bool op[nx];
priority_queue<pair<int, int>> pq;
vector<pair<int, int>> v[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=m; i++) cin>>l>>r>>x, v[l].push_back({-l+x, i}), v[r+1].push_back({i, i});
for (int i=1; i<=n; i++)
{
for (auto [x, y]:v[i])
{
if (!op[y]) op[y]=1, pq.push({x, y});
else op[y]=0;
}
while (!pq.empty()&&!op[pq.top().second]) pq.pop();
cout<<(pq.empty()?0:pq.top().first+i)<<' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |