# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167004 | abil | Trading (IZhO13_trading) | C++14 | 944 ms | 29072 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>
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long
using namespace std;
const int N = (3e5 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);
int l[N], r[N], x[N], ans[N];
set<pair<int,int >> st, dt, cur_set;
void del(pair<int,int > pr){
cur_set.erase(cur_set.find({l[pr.sc] - x[pr.sc], pr.sc}));
}
void add(pair<int,int > pr){
dt.insert({r[pr.sc] + 1, pr.sc});
cur_set.insert({l[pr.sc] - x[pr.sc], pr.sc});
}
int get(int pos){
int res = 0;
if(!cur_set.empty()){
res = pos - cur_set.begin() -> fr;
}
return res;
}
main()
{
int n, m;
cin >> n >> m;
for(int i = 1;i <= m; i++){
scanf("%d%d%d", &l[i], &r[i], &x[i]);
st.insert({l[i], i});
}
for(int i = 1;i <= n; i++){
while(!dt.empty() && dt.begin() -> fr == i){
del(*dt.begin());
dt.erase(dt.begin());
}
while(!st.empty() && st.begin() -> fr == i){
add(*st.begin());
st.erase(st.begin());
}
printf("%d ", get(i));
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |