Submission #21856

#TimeUsernameProblemLanguageResultExecution timeMemory
21856ulnaTrading (IZhO13_trading)C++11
100 / 100
216 ms4364 KiB
#include <bits/stdc++.h> using namespace std; // why am I so weak int n, m; int dat[600055]; void update(int l, int r, int val) { l += n, r += n; for (; l < r; l >>= 1, r >>= 1) { if (l & 1) { dat[l] = max(dat[l], val); l++; } if (r & 1) { r--; dat[r] = max(dat[r], val); } } } int query(int id) { int res = -INT_MAX; for (id += n; id > 0; id >>= 1) { res = max(res, dat[id]); } return res; } int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n + n; i++) { dat[i] = -INT_MAX; } while (m--) { int x, y, z; scanf("%d %d %d", &x, &y, &z); x--; update(x, y, z - x); } for (int i = 0; i < n; i++) { if (i) printf(" "); int res = query(i); if (res == -INT_MAX) res = 0; else res += i; printf("%d", res); } puts(""); return 0; }

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:34:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
trading.cpp:42:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &x, &y, &z);
                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...