제출 #895762

#제출 시각아이디문제언어결과실행 시간메모리
895762heeheeheehaaw거래 (IZhO13_trading)C++17
100 / 100
349 ms32784 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; set<pair<int, int>> s; for(int i = 1; i <= n; i++) { for(auto it : v[i]) { if(it > 0) { int nr = val[it] - i + 1; s.insert(make_pair(nr, it)); val[it] = nr; } else s.erase(s.find(make_pair(val[-it], -it))); } if(s.empty()) cout<<0<<" "; else cout<<(int)(s.rbegin()->first) + i - 1<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...