Submission #690024

#TimeUsernameProblemLanguageResultExecution timeMemory
690024moonheroTrading (IZhO13_trading)C++17
0 / 100
128 ms588 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3e5 + 5; ll r[N * 4], tc[N * 4], u[N * 4]; void push (int v, int tl, int tr) { if (u[v]) { int tm = (tl + tr) / 2; // cout << tl << ' ' << tr << ' ' << u[v] << '\n'; // if (tm == tl) { // // cout << tl << '\n'; // r[v * 2] = max(r[v * 2], u[v]); // } // if (tm + 1 == tr) { // // cout << tr << '\n'; // r[v * 2 + 1] = max(r[v * 2 + 1], u[v] + 1); // } u[v * 2] = u[v], u[v * 2 + 1] = u[v] + (tm - tl + 1); u[v] = 0, tc[v] = 0; } } void upd (int v, int tl, int tr, int l, int r, ll val) { if (tl >= l && tr <= r) { // cout << tl << ' ' << tr << ' ' << val + tl - l << '\n'; tc[v]++, u[v] = max(u[v], val + tl - l); return; } if (tl > r || tr < l) return; int tm = (tl + tr) / 2; push(v, tl, tr); upd(v * 2, tl, tm, l, r, val); upd(v * 2 + 1, tm + 1, tr, l, r, val); } void out (int v, int tl, int tr) { if (tl == tr) { cout << u[v] << ' '; return; } int tm = (tl + tr) / 2; push(v, tl, tr); out(v * 2, tl, tm); out(v * 2 + 1, tm + 1, tr); } int main () { freopen("trading.in", "r", stdin); freopen("trading.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i <= n * 4; i++) r[i] = 0, u[i] = 0, tc[i] = 0; int q; cin >> q; while (q--) { int l, r, x; cin >> l >> r >> x; upd(1, 1, n, l, r, x); } out(1, 1, n); } }

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:43:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     freopen("trading.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
trading.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     freopen("trading.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...