fork download
  1. #include <stdio.h>
  2. typedef long long ll;
  3. const int n_ = 1e6 + 1;
  4.  
  5. int n, m, k;
  6. ll arr[n_], tree[n_ * 2];
  7.  
  8. ll init(int now, int lft, int rgt) {
  9. if (lft == rgt) return tree[now] = arr[lft];
  10. return tree[now] = init(now * 2, lft, (lft + rgt) / 2) + init(now * 2 + 1, (lft + rgt) / 2 + 1, rgt);
  11. }
  12.  
  13. void upd(int now, int idx, int lft, int rgt, ll dif) {
  14. if (idx < lft || rgt < idx) return;
  15. tree[now] += dif;
  16. if (lft != rgt) {
  17. upd(now * 2, lft, (lft + rgt) / 2, dif);
  18. upd(now * 2 + 1, (lft + rgt) / 2 + 1, rgt, dif);
  19. }
  20. }
  21.  
  22. ll qry(int now, int bgn, int end, int lft, int rgt) {
  23. if (bgn < lft || rgt < end) return 0;
  24. if (lft <= bgn && end <= rgt) return tree[now];
  25. return qry(now * 2, bgn, end, lft, (lft + rgt) / 2) + qry(now * 2 + 1, bgn, end, (lft + rgh) / 2 + 1, rgt);
  26. }
  27.  
  28. int main() {
  29. scanf("%d %d %d", &n, &m, &k);
  30. for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  31.  
  32. init(1, 1, n);
  33.  
  34. for (int i = 0; i < m + k; i++) {
  35. ll a, b, c;
  36. scanf("%lld %lld %lld", &a, &b, &c);
  37. if (x == 1)
  38. arr[b] = c, upd(1, b, 1, n, c - arr[i]);
  39. else
  40. printf("%lld\n", qry(1, b, c, 1, n));
  41. }
  42.  
  43.  
  44. return 0;
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void upd(int, int, int, int, ll)’:
prog.cpp:17:41: error: too few arguments to function ‘void upd(int, int, int, int, ll)’
   upd(now * 2, lft, (lft + rgt) / 2, dif);
                                         ^
prog.cpp:13:6: note: declared here
 void upd(int now, int idx, int lft, int rgt, ll dif) {
      ^~~
prog.cpp:18:49: error: too few arguments to function ‘void upd(int, int, int, int, ll)’
   upd(now * 2 + 1, (lft + rgt) / 2 + 1, rgt, dif);
                                                 ^
prog.cpp:13:6: note: declared here
 void upd(int now, int idx, int lft, int rgt, ll dif) {
      ^~~
prog.cpp: In function ‘ll qry(int, int, int, int, int)’:
prog.cpp:25:90: error: ‘rgh’ was not declared in this scope
  return qry(now * 2, bgn, end, lft, (lft + rgt) / 2) + qry(now * 2 + 1, bgn, end, (lft + rgh) / 2 + 1, rgt);
                                                                                          ^~~
prog.cpp: In function ‘int main()’:
prog.cpp:37:7: error: ‘x’ was not declared in this scope
   if (x == 1)
       ^
stdout
Standard output is empty