Submission #874440

#TimeUsernameProblemLanguageResultExecution timeMemory
87444012345678Trading (IZhO13_trading)C++17
100 / 100
143 ms25264 KiB
#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 timeMemoryGrader output
Fetching results...