제출 #538890

#제출 시각아이디문제언어결과실행 시간메모리
538890GioChkhaidze거래 (IZhO13_trading)C++14
100 / 100
177 ms12620 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n, m, L, R, X, inf = 1e9; vector < int > v(4 * N, -inf); void upd(int h, int l, int r) { if (r < L || R < l) return ; if (L <= l && r <= R) { v[h] = max(v[h], X - L); return ; } upd((h << 1), l, ((l + r) >> 1)); upd(((h << 1) | 1), ((l + r) >> 1) + 1, r); } void dfs(int h, int l, int r, int mx) { if (l == r) { if (mx == -inf) cout << 0 << " "; else cout << l + mx << " "; return ; } dfs((h << 1), l, ((l + r) >> 1), max(mx, v[(h << 1)])); dfs(((h << 1) | 1), ((l + r) >> 1) + 1, r, max(mx, v[((h << 1) | 1)])); } main () { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> n >> m; for (int i = 1; i <= m; ++i) { cin >> L >> R >> X; upd(1, 1, n); } dfs(1, 1, n, v[1]); }

컴파일 시 표준 에러 (stderr) 메시지

trading.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...