# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681952 | speedyArda | Trading (IZhO13_trading) | C++14 | 490 ms | 44696 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;
using ll = long long;
const int MAXN = 300005;
vector<vector<pair<ll, pair<ll, ll>>>> beginr(MAXN), endr(MAXN);
int main()
{
ll n, m;
cin >> n >> m;
multiset<pair<ll, pair<ll, ll>>> curr;
for (int i = 1; i <= m; i++)
{
pair<ll, pair<ll, ll>> temp;
ll f, s, t;
cin >> f >> s >> t;
temp.first = t;
temp.second.first = f;
temp.second.second = s;
beginr[f].push_back(temp);
endr[s + 1].push_back(temp);
}
for (int day = 1; day <= n; day++)
{
for (pair<ll, pair<ll, ll>> e : endr[day])
{
curr.erase(curr.find({e.first - e.second.first, {e.second.first, e.second.second}}));
}
for (pair<ll, pair<ll, ll>> e : beginr[day])
{
curr.insert({e.first - e.second.first, {e.second.first, e.second.second}});
}
pair<ll, pair<ll, ll>> maxi;
if (curr.size() > 0)
{
auto it = curr.end();
it--;
maxi = *(it);
cout << (maxi.first + maxi.second.first) + day - maxi.second.first;
}
else
{
cout << "0";
}
// if (day == 5)
// cout << maxi.first << " " << maxi.second << "\n";
if (day != n)
cout << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |