# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894586 | Andrey | Trading (IZhO13_trading) | C++14 | 141 ms | 26552 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;
vector<pair<int,int>> haha[500002];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,q,l,r,a;
cin >> n >> q;
for(int i = 0; i < q; i++) {
cin >> l >> r >> a;
haha[l].push_back({a-l,r});
}
priority_queue<pair<int,int>> idk;
for(int i = 1; i <= n; i++) {
for(int j = 0; j < haha[i].size(); j++) {
idk.push(haha[i][j]);
}
while(!idk.empty() && idk.top().second < i) {
idk.pop();
}
if(idk.empty()) {
cout << 0 << " ";
}
else {
cout << idk.top().first+i << " ";
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |