Submission #895761

#TimeUsernameProblemLanguageResultExecution timeMemory
895761heeheeheehaawTrading (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; map<int, int> mp; for(int i = 1; i <= n; i++) { for(auto it : v[i]) { if(it > 0) { int nr = val[it] - i + 1; mp[nr] = it; val[it] = nr; } else mp.erase(mp.find(val[-it])); } if(mp.empty()) cout<<0<<" "; else cout<<(int)(mp.rbegin()->first) + i - 1<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...