Submission #895758

#TimeUsernameProblemLanguageResultExecution timeMemory
895758heeheeheehaawTrading (IZhO13_trading)C++17
0 / 100
2 ms8540 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int val[300005]; vector<int> v[300005]; bool visited[300005]; signed main() { int n, m; cin>>n>>m; for(int i = 1; i <= m; i++) { int st, dr, x; cin>>st>>dr>>x; val[i] = x; v[st].push_back(i); v[dr + 1].push_back(-i); } deque<pair<int, int>> dq; for(int i = 1; i <= n; i++) { for(auto it : v[i]) { if(it > 0) { int nr = val[it] - i + 1; while(!dq.empty() && dq.back().first <= nr) dq.pop_back(); dq.push_back({nr, it}); } else visited[-it] = true; } while(!dq.empty() && visited[dq.front().second]) dq.pop_front(); if(dq.empty()) cout<<0<<" "; else cout<<dq.front().first + i - 1<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...