# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
755600 | pera | Trading (IZhO13_trading) | C++17 | 485 ms | 34380 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
const int N = 3e5 + 1;
vector<int> g[N];
vector<int> y[N];
main(){
int n , m;cin >> n >> m;
vector<int> a(n + 1);
for(int i = 1;i <= m;i ++){
int l , r , x;cin >> l >> r >> x;
g[l].push_back(x - l);
y[r + 1].push_back(x - l);
}
multiset<int> s;
for(int i = 1;i <= n;i ++){
for(int j = 0;j < g[i].size();j ++) s.insert(g[i][j]);
for(int j = 0;j < y[i].size();j ++) s.erase(s.find(y[i][j]));
cout << (s.empty() ? 0 : *--s.end() + i) << " ";
//cout << i << " ";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |