# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895762 | heeheeheehaaw | Trading (IZhO13_trading) | C++17 | 349 ms | 32784 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 int long long
using namespace std;
int val[300005];
vector<int> v[300005];
bool visited[300005];
signed main()
{
int n, m;
cin>>n>>m;
for(int i = 1; i <= m; i++)
{
int st, dr, x;
cin>>st>>dr>>x;
val[i] = x;
v[st].push_back(i);
v[dr + 1].push_back(-i);
}
deque<pair<int, int>> dq;
map<int, int> mp;
set<pair<int, int>> s;
for(int i = 1; i <= n; i++)
{
for(auto it : v[i])
{
if(it > 0)
{
int nr = val[it] - i + 1;
s.insert(make_pair(nr, it));
val[it] = nr;
}
else s.erase(s.find(make_pair(val[-it], -it)));
}
if(s.empty()) cout<<0<<" ";
else cout<<(int)(s.rbegin()->first) + i - 1<<" ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |