# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314276 | BeanZ | Trading (IZhO13_trading) | C++14 | 201 ms | 13924 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.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 3e5 + 5;
struct viet{
ll l, r, x;
bool operator <(const viet &o) const{
return l < o.l;
}
}a[N];
struct lpl{
ll l, r, x;
bool operator <(const lpl &o) const{
return (l - x) > (o.l - o.x);
}
};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++){
cin >> a[i].l >> a[i].r >> a[i].x;
}
sort(a + 1, a + m + 1);
ll now = 1;
priority_queue<lpl> pq;
for (int i = 1; i <= n; i++){
while (now <= m && a[now].l == i){
lpl x = {a[now].l, a[now].r, a[now].x};
pq.push(x);
now++;
}
while (pq.size()){
if (pq.top().r < i) pq.pop();
else break;
}
if (pq.size() == 0) cout << 0 << " ";
else {
cout << i - pq.top().l + pq.top().x << " ";
}
}
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |