# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502127 | Aktan | Trading (IZhO13_trading) | C++17 | 547 ms | 33500 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define ft first
#define sc second
using namespace std;
const int mod=1e9+7,INF=1e17,N=3e5+5;
int a[N],b[N],c[N];
main(){
int n,m;
cin >> n >> m;
multiset<pair<pair<int,int>,int>> v;
for(int i=0;i<m;i++){
cin >> a[i] >> b[i] >> c[i];
v.insert({{a[i],b[i]},c[i]-a[i]});
}
multiset<pair<int,int>> v1;
for(int i=1;i<=n;i++){
while(!v.empty() && v.begin()->ft.ft<=i){
v1.insert({v.begin()->sc,v.begin()->ft.sc});
v.erase(v.begin());
}
while(!v1.empty() && (--v1.end())->sc < i){
v1.erase((--v1.end()));
}
if(v1.empty()){
cout << 0 << " ";
}
else{
auto it=v1.end();
it--;
cout << it->ft+i << " ";
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |