# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
380347 | ritul_kr_singh | Trading (IZhO13_trading) | C++17 | 443 ms | 35284 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;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
signed main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, m; cin >> n >> m;
int a[m], ans[n];
vector<int> starts[n], ends[n];
for(int i=0, l, r; i<m; ++i){
cin >> l >> r >> a[i];
starts[l-1].push_back(i);
ends[r-1].push_back(i);
a[i] -= l-1;
}
multiset<int> s;
for(int i=0; i<n; ++i){
for(int j : starts[i]) s.insert(a[j]);
ans[i] = s.empty() ? 0LL : *s.rbegin() + i;
for(int j : ends[i]) s.erase(s.find(a[j]));
}
for(int i : ans) cout << i << ' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |