Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define ff first
- #define ss second
- int main()
- {
- int n, m;
- cin>>n>>m;
- vector<array<ll int, 3>> tws(m);
- for(auto &[t, w, s]: tws) cin>>t>>w>>s;
- vector<ll int> ans(n);
- set<pair<ll int, ll int>> returnTime;
- set<int> st;
- for(int i=0; i<n; i++)
- st.insert(i);
- for(auto [t, w, s]: tws)
- {
- while(returnTime.size() && (*returnTime.begin()).ff<=t)
- {
- st.insert((*returnTime.begin()).ss);
- returnTime.erase(returnTime.begin());
- }
- if(!st.size()) continue;
- ans[*st.begin()] += w;
- returnTime.insert({t+s, *st.begin()});
- st.erase(st.begin());
- }
- for(auto e: ans)
- cout<<e<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment