# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
970449 | jadai007 | Trading (IZhO13_trading) | C++14 | 131 ms | 22968 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>> vc[maxn];
int ans[maxn];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> q;
for (int i = 1; i <= q; ++i){
int l, r, val; cin >> l >> r >> val;
vc[l].push_back({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 < vc[i].size(); ++j) pq.push({vc[i][j].second, vc[i][j].first});
if (!pq.empty()) ans[i] = pq.top().first + i;
else ans[i] = 0;
cout << ans[i] << ' ';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |