제출 #988072

#제출 시각아이디문제언어결과실행 시간메모리
988072long거래 (IZhO13_trading)C++17
100 / 100
397 ms47228 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int N = 3e5 + 10; int seg[N * 4], laz[N * 4]; void push(int id) { int &t = laz[id]; laz[id * 2] += t; laz[id * 2 + 1] += t; seg[id * 2] += t; seg[id * 2 + 1] += t; t = 0; } void upd(int id, int l, int r, int u, int v, int c) { if (l > v || r < u) return; if (l >= u && r <= v) { laz[id] += c; seg[id] += c; return; } push(id); int m = (l + r) / 2; upd(id * 2, l, m, u, v, c); upd(id * 2 + 1, m + 1, r, u, v, c); seg[id] = max(seg[id * 2], seg[id * 2 + 1]); } void run(int id, int l, int r, int p, int v) { if (l > p || r < p) return; if (l == r) { seg[id] = v; laz[id] = 0; return; } push(id); int m = (l + r) / 2; run(id * 2, l, m, p, v); run(id * 2 + 1, m + 1, r, p, v); seg[id] = max(seg[id * 2], seg[id * 2 + 1]); } vector <int> event[N]; int l[N], r[N], v[N]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); seg[1] = laz[1] = -1e8; int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> l[i] >> r[i] >> v[i]; event[l[i]].pb(i); event[r[i] + 1].pb(-i); } for (int i = 1; i <= n; i++) { upd(1, 1, m, 1, m, 1); for (auto x : event[i]) { if (x > 0) { run(1, 1, m, x, v[x]); } else { run(1, 1, m, -x, -1e8); } } cout << max(0LL, seg[1]) << " "; } return 0; }

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

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