# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320507 | sofapuden | Trading (IZhO13_trading) | C++14 | 515 ms | 19648 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>
using namespace std;
int main(){
int n, m; cin >> n >> m;
vector<array<int,3>> toAdd, toRem;
for(int i = 0; i < m; ++i){
int l, r, x; cin >> l >> r >> x;
toAdd.push_back({l,r,x-l});
toRem.push_back({r,l,x-l});
}
sort(toAdd.begin(), toAdd.end());
sort(toRem.begin(), toRem.end());
int cnl = 0, cnr = 0;
map<int,int> M;
for(int i = 1; i <= n; ++i){
while(toAdd[cnl][0] == i){
M[toAdd[cnl++][2]]++;
}
while(toRem[cnr][0] == i-1){
M[toRem[cnr][2]]--;
if(!M[toRem[cnr][2]]){
M.erase(toRem[cnr][2]);
}
cnr++;
}
if(M.empty()){
cout << "0 ";
}
else{
cout << prev(M.end())->first + i << " ";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |