# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
969710 | SeenSiravit | Trading (IZhO13_trading) | C++14 | 416 ms | 35272 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |