DCP-438: Chowdhury Saheb & the Queries Back to All Problems

Medium Data Structures > Segment Tree/Interval Tree


You are given an array of **N** integers. You need to perform **Q** queries. In each query, you have to perform any of these two types of operation: **1 X C** : Calculate and print the number of maximum consecutive elements from index **X** such that, the sum of these elements doesn’t exceed **C**. **( 1 ≤ X ≤ N, 1 ≤ C ≤ 10^12 )** **2 X Y** : Change the value of **Xth** index of the array to **Y**. You need not to print anything here. **( 1 ≤ X ≤ N, 0 ≤ Y ≤ 10^6 )** Input: ------ The input starts with two integers **N (1 ≤ N ≤ 10^5)** and **Q (1 ≤ Q ≤ 10^5)** denoting the number of elements of the array and the total number of queries. The second line consist of **N** integers **ar[i] (0 ≤ ar[i] ≤ 10^6)** where **(1 ≤ i ≤ N)**. The next **Q** lines contains any of two types of query described above. Output: ------- For each query, perform the query as described above. Sample Input ------------ 5 4 1 2 4 5 6 1 1 3 1 3 15 2 2 7 1 1 3 Sample Output ------------- 2 3 1


Problem Setter:

Emrul Chowdhury

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

63/143

Solve/Submission

Ranking

# User Language Timing
01 tariqiitju Cpp 0.07s
02 FariD Cpp 0.07s
03 ovis96 Cpp 0.07s
04 feodorv C 0.10s
05 mir003 Cpp 0.10s
06 ehsan_sshuvo96 Cpp 0.10s
07 prateepm Cpp14 0.10s
08 Mahagoni Cpp 0.10s
09 kissu_pari_na Cpp14 0.11s
10 prodipdatta7 Cpp14 0.11s
11 skmonir Cpp 0.13s
12 _GhOstMan_ Cpp 0.13s
13 rayhan50001 Cpp 0.34s
14 Rajan_sust Cpp14 0.41s
15 emrul Cpp 0.43s
16 Pure_Protea Cpp14 0.43s
17 bu_hridoy Cpp 0.45s
18 pulak_ict_mbstu Cpp14 0.45s
19 anik_JU Cpp 0.46s
20 clkjwdhc Cpp 0.46s
21 SakibAlamin Cpp 0.46s
22 ssavi Cpp 0.48s
23 Sarwar05 Cpp 0.48s
24 Silent_Warrior Cpp 0.57s
25 nafiamahjabin Cpp 0.98s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support