Qualified's blog

By Qualified, history, 4 years ago, In English

You are given a number $$$n$$$ and a number $$$m$$$ and an array $$$a$$$ of $$$n$$$ numbers and 1 type of query. All of the numbers below are 0 based indexing.

1) Given 3 numbers, $$$l$$$, $$$r$$$ , $$$x$$$. You add all the numbers from l to r(inclusive) by x. For example if the initial array was {5, 4, 3, 9, 2} and the query was {0, 2, 5} then the array would become {10, 9, 8, 9, 2}. Also, print the array.

After each query, store the new array as array $$$a$$$.

At the end print the array a.

m describes the number of queries being asked.

Example:

4 3
1 9 2 2
2 2 3
0 3 5
2
Output:

10
6 14 10 7

Should be less that $$$O(n)$$$

  • Vote: I like it
  • -10
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it -10 Vote: I do not like it

Auto comment: topic has been updated by Qualified (previous revision, new revision, compare).

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it
  • »
    »
    4 years ago, # ^ |
      Vote: I like it -18 Vote: I do not like it

    My bad, I meant for it to be less than $$$O(n)$$$. The printing array takes $$$O(n)$$$.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Qualified (previous revision, new revision, compare).