Submission #969711

#TimeUsernameProblemLanguageResultExecution timeMemory
969711SeenSiravitTrading (IZhO13_trading)C++14
0 / 100
1 ms2396 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]; int main(){ ios::sync_with_stdio(0),cin.tie(0); cin>> n >> m; for(int i=1;i<=m;i++){ cin>> t[i][0] >> t[i][1] >> t[i][2]; t[i][2] = t[i][2] - t[i][0]; } sort(t+1 , t+1+m); // for(int i=1;i<=m;i++) printf("%d %d %d\n",t[i][1] , t[i][0] , t[i][2]); int idx = 1; deque<int> dq; for(int i=1;i<=n;i++){ // clear past data while(!dq.empty() && t[dq.front()][1]<i) dq.pop_front(); // add new data while(idx<=m && t[idx][0]<=i){ while(!dq.empty() && t[dq.back()][2] <= t[idx][2]) dq.pop_back(); dq.push_back(idx); idx++; } ans[i] = (dq.empty() ? 0 : t[dq.front()][2] + i); } for(int i=1;i<=n;i++) cout<< ans[i] << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...