An (interesting, short) query-update problem

Revision en1, by FoolForCS, 2016-08-24 23:08:40

You are given an array of size N.
Update operation : < X, Y, L, R > : Add value Y to every X th element in [ L , R ].
Query operation : < X > : Return the value at position X .

Sample: Given array [1, 2, 3, 4, 5, 6]
1. update 2 1 2 5
The array will be transormed to [1, 2, (3 + 1), 4, (5 + 1), 6]
Any thoughts on the best time complexity we can achieve for the operations (online)?

Tags query, update

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English FoolForCS 2016-08-24 23:08:40 489 Initial revision (published)