# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
508128 | ac2hu | Trading (IZhO13_trading) | C++14 | 11 ms | 14540 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 + 10;
int n,m;
int a[N];
struct tr{
int l,r,x;
} tr[N];
vector<int> in[N],out[N];
signed main(){
iostream::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
cin >> n >> m;
for(int i = 0;i<n;i++){
cin >> tr[i].l >> tr[i].r >> tr[i].x;
tr[i].l--;
tr[i].r--;
in[tr[i].l].push_back(i);
out[tr[i].r].push_back(i);
}
multiset<int> se;
int c = 0;
for(int i = 0;i<n;i++){
for(auto e : in[i]){
se.insert(tr[e].x - c);
}
// for(auto e : se)cout << e << " ";
// cout << endl;
if(se.size() == 0)
a[i] = 0;
else
a[i] = *se.rbegin() + c;
c++;
for(auto e : out[i]){
int val = tr[e].x - tr[e].l;
// cerr << e << " " << val << endl;
se.erase(se.find(val));
}
}
for(int i = 0;i<n;i++)
cout << a[i] << " ";
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |