CF1136E.Nastya Hasn't Written a Legend

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In this task, Nastya asked us to write a formal statement.

An array aa of length nn and an array kk of length n1n-1 are given. Two types of queries should be processed:

  • increase aia_i by xx . Then if ai+1<ai+kia_{i+1} < a_i + k_i , ai+1a_{i+1} becomes exactly ai+kia_i + k_i ; again, if ai+2<ai+1+ki+1a_{i+2} < a_{i+1} + k_{i+1} , ai+2a_{i+2} becomes exactly ai+1+ki+1a_{i+1} + k_{i+1} , and so far for ai+3a_{i+3} , ..., ana_n ;
  • print the sum of the contiguous subarray from the ll -th element to the rr -th element of the array aa .

It's guaranteed that initially ai+kiai+1a_i + k_i \leq a_{i+1} for all 1in11 \leq i \leq n-1 .

输入格式

The first line contains a single integer nn ( 2n1052 \leq n \leq 10^{5} ) — the number of elements in the array aa .

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 109ai109-10^{9} \leq a_i \leq 10^{9} ) — the elements of the array aa .

The third line contains n1n-1 integers k1,k2,,kn1k_1, k_2, \ldots, k_{n-1} ( 106ki106-10^{6} \leq k_i \leq 10^{6} ) — the elements of the array kk .

The fourth line contains a single integer qq ( 1q1051 \leq q \leq 10^{5} ) — the number of queries.

Each of the following qq lines contains a query of one of two types:

  • if the query has the first type, the corresponding line contains the character '+' (without quotes), and then there are two integers ii and xx ( 1in1 \leq i \leq n , 0x1060 \leq x \leq 10^{6} ), it means that integer xx is added to the ii -th element of the array aa as described in the statement.
  • if the query has the second type, the corresponding line contains the character 's' (without quotes) and then there are two integers ll and rr ( 1lrn1 \leq l \leq r \leq n ).

输出格式

For each query of the second type print a single integer in a new line — the sum of the corresponding subarray.

输入输出样例

  • 输入#1

    3
    1 2 3
    1 -1
    5
    s 2 3
    + 1 2
    s 1 2
    + 3 1
    s 2 3
    

    输出#1

    5
    7
    8
    
  • 输入#2

    3
    3 6 7
    3 1
    3
    + 1 3
    + 2 4
    s 1 3
    

    输出#2

    33
    

说明/提示

In the first example:

  • after the first change a=[3,4,3]a = [3, 4, 3] ;
  • after the second change a=[3,4,4]a = [3, 4, 4] .

In the second example:

  • after the first change a=[6,9,10]a = [6, 9, 10] ;
  • after the second change a=[6,13,14]a = [6, 13, 14] .
首页