# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111912 | vjudge1 | Trading (IZhO13_trading) | C++17 | 3 ms | 14672 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 task "TEST"
#define task2 "A"
#define pl pair<ll, ll>
#define VI vector<ll>
#define pf push_front
#define pb push_back
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (int i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (int i=a; i>=b; i+=c)
using namespace std;
using ll = long long;
using lll = __int128;
using ull = unsigned long long;
using ulll = unsigned __int128;
const int Mod = 1e9+7;
const int maxn = 3e5+1;
const ll Inf = 3e9;
pl A[maxn+1];
ll n, m;
vector<ll> add[maxn+1], del[maxn+1];
set<ll> S;
ll a, b, c, res[maxn+1];
void Read()
{
cin >> n >> m;
FOR(i, 1, m, 1) {
cin >> a >> b >> c;
add[a].pb(c-a);
del[b+1].pb(c-a);
}
}
void Solve()
{
FOR(i, 1, n, 1) {
for(auto v : add[i]) S.insert(v);
for(auto v : del[i]) S.erase(S.find(v));
res[i] = (S.size() ? *S.rbegin() + i : 0);
}
FOR(i, 1, n, 1) cout << res[i] << " ";
}
int main()
{
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; //Sieve();
for (t=1; t--;)
{
Read(); Solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |