Submission #969688

#TimeUsernameProblemLanguageResultExecution timeMemory
969688SeenSiravitTrading (IZhO13_trading)C++14
100 / 100
412 ms41280 KiB
#include<bits/stdc++.h> #define ll long long #define ar array using namespace std; const int mxN = 3e5 + 5; int n,m; ar<int,3> t[mxN]; ll ans[mxN]; vector<int> st[mxN] , en[mxN]; int main(){ cin>> n >> m; for(int i=1;i<=m;i++){ cin>> t[i][1] >> t[i][0] >> t[i][2]; t[i][2] = t[i][2] - t[i][1]; st[t[i][1]].push_back(i); en[t[i][0]+1].push_back(i); } set<ar<int , 2>> s; for(int i=1;i<=n;i++){ for(auto idx : st[i]) s.insert({t[idx][2] , idx}); for(auto idx : en[i]) s.erase({t[idx][2] , idx}); ans[i] = (s.empty() ? 0 : (*s.rbegin())[0] + i); } for(int i=1;i<=n;i++) cout<< ans[i] << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...