# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037074 | vjudge1 | Trading (IZhO13_trading) | C++17 | 165 ms | 23224 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 REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define PR(a,n) { cerr << #a << " = "; FOR(_,1,n) cerr << a[_] << ' '; cerr << endl; }
#define PR0(a,n) { cerr << #a << " = "; REP(_,n) cerr << a[_] << ' '; cerr << endl; }
#define debug(x) cerr << #x << " = " << x << endl
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define __builtin_popcount __builtin_popcountll
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
template <class T, class T2> ostream &operator<<(ostream &o, pair<T, T2> p)
{
o << "(" << p.first << ", " << p.second << ")";
return o;
}
const int M = 3e5 + 5;
// (firstVal, type)
vector<pair<int, bool>> queries[M];
signed main()
{
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
int addVal = 0;
while (q--)
{
int l, r, fi;
cin >> l >> r >> fi;
queries[l].push_back({fi, 1});
queries[r + 1].push_back({fi + r - l + 1, 0});
}
multiset <int, greater<int>> curVals;
for (int x = 1; x <= n; ++x)
{
for (auto [val, type]: queries[x])
{
if (type)
curVals.insert(val - addVal);
else
curVals.erase(curVals.find(val - addVal));
}
cout << (curVals.size()? *curVals.begin() + addVal: 0) << " ";
++addVal;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |