# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896958 | borisAngelov | Trading (IZhO13_trading) | C++17 | 119 ms | 23068 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 maxn = 300005;
int n, q;
vector<pair<int, int>> byL[maxn];
int answer[maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> q;
for (int i = 1; i <= q; ++i)
{
int l, r, val;
cin >> l >> r >> val;
byL[l].push_back(make_pair(r, val - l));
}
priority_queue<pair<int, int>> pq;
for (int i = 1; i <= n; ++i)
{
while (!pq.empty() && pq.top().second < i)
{
pq.pop();
}
for (int j = 0; j < byL[i].size(); ++j)
{
pq.push(make_pair(byL[i][j].second, byL[i][j].first));
}
if (!pq.empty())
{
answer[i] = pq.top().first + i;
}
else
{
answer[i] = 0;
}
}
for (int i = 1; i <= n; ++i)
{
cout << answer[i] << ' ';
}
cout << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |