# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336570 | nickmet2004 | Trading (IZhO13_trading) | C++11 | 375 ms | 31072 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;
const int N = 3e5 +5;
int n , m , ans[N] , oo = -2e9;
vector<int> L[N], R[N];
int main (){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= m; ++i){
int l , r , c;
cin >> l >> r >> c;
L[l].emplace_back(c - l); R[r].emplace_back(c - l);
}
multiset<int> s;
s.insert(oo);
for(int i = 1; i <= n; ++i){
for(int x : L[i])s.insert(x);
int y = *s.rbegin();
if(y == oo) ans[i] = 0;
else ans[i] = i + y;
for(int x : R[i])s.erase(s.find(x));
}
for(int i = 1; i<= n; ++i) cout << ans[i] << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |