3954 - The Evarista Store 3954 - La tienda de Evarista 3954 - The Evarista Store

Statistics Sub: 189 | AC: 76 | AC%: 40,21 | Score: 1,83
Created by Jesús Yanser Vega Labarcena
Added by jvega (2018-02-20)
Limits
Total Time: 900 MS | Test Time: 500 MS |Memory: 512 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

Evarista, Pánfilo's friend, has always felt the great need to do business. She would like to sell N (1 <= N <= 5 * 10^4) items, with the aim of being able to buy the new appliances that arrive at the store. She has set up a private point of sale in the house of Pánfilo, where she currently exhibits her articles through a digital screen.
As usual, she spends every day in the store, discovers that they are frequently changing the price of household appliances, so she is afraid that her money will not be enough to buy what she wants. Afraid she presents her problem to Pánfilo, and he proposes that as the price changes in the store she modifies the value of some of the N items she sells. As this change must be made quickly without the clients of Evarista noticing the difference, they ask you to help them make a program that allows the following operations:
  • Each time that Evarista write 1 the program must read two values: i (1 <= i <= 5*10^4) (the position of the i-th item to which she wants to change the price) and p (the amount of money that must be increased to the i-th item that is being displayed).
  • When writing 2 the program must read two positions: i(1 <= i <= 5 * 10^4) (the position of the first item from which you want to start adding) and j (1 <= j <= 5 * 10^4) (the position of the last item that you want to add).
PS: As Evarista is a woman of very advanced age, she tends to easily forget the value she must enter to obtain the sum of her articles in a range. Sometimes unknowingly enters an X value (2 <= X <= 20), so Pánfilo asks you that on those occasions if X is an even value you return to Evarista the sum of the items price in a given range, in case X is odd (and X! = 1), "Error" must be printed.
Evarista, la amiga de Pánfilo, siempre ha sentido la gran necesidad de hacer negocios. A ella le gusta vender N (1 <= N <= 5 * 10^4) artículos, con el objetivo de poder comprar los nuevos electrodomésticos que llegan a la tienda. Ella ha montado un punto de venta particular en la casa de Panfilo, donde actualmente exhibe sus artículos a través de una pantalla digital.

Como de costumbre ella pasa todos los días por la tienda y descubre que frecuentemente están cambiando el precio de los electrodomésticos, por lo que teme que su dinero no alcance para comprar lo que ella desea. Asustada le presenta su problema a Pánfilo, y este le propone que a medida que cambien el precio en la tienda ella modifique el valor de algunos de los N artículos que vende. Como este cambio debe hacerse rápido sin que los clientes de Evarista noten la diferencia, ella le piden ayuda a usted para que haga un programa que permita hacer las siguientes operaciones:
  • Cada vez que Evarista escriba 1 a continuación el programa debe leer dos valores mas i (1 <= i <= 5 * 10^4) (la posición del i-th artículo al que le quiere cambiar el precio) y p (la cantidad de dinero que se debe aumentar al artículo i-th que se está exhibiendo).
  • Cuando escriba 2 el programa debe leer dos posiciones más i (1 <= i <= 5 * 10^4) (la posición del primer artículo a partir del cual quiere comenzar a sumar) y j (1 <= j <= 5 * 10^4) (la posición del último artículo que se desea sumar).
PD: Como Everista es una mujer de edad muy avanzada tiende a olvidar con facilidad el valor que debe introducir para obtener la suma de sus artículos en un rango. A veces sin darse cuenta entra un valor X (2 <= X <= 20), por lo que Pánfilo le pide a usted que en esas ocasiones si X es un valor par le devuelva a Evarista la suma de los artículos N en un rango dado, en el caso de que X sea impar (X != 1) se debe devolver "Error".
Evarista, Pánfilo's friend, has always felt the great need to do business. She would like to sell N (1 <= N <= 5 * 10^4) items, with the aim of being able to buy the new appliances that arrive at the store. She has set up a private point of sale in the house of Pánfilo, where she currently exhibits her articles through a digital screen.
As usual, she spends every day in the store, discovers that they are frequently changing the price of household appliances, so she is afraid that her money will not be enough to buy what she wants. Afraid she presents her problem to Pánfilo, and he proposes that as the price changes in the store she modifies the value of some of the N items she sells. As this change must be made quickly without the clients of Evarista noticing the difference, they ask you to help them make a program that allows the following operations:
  • Each time that Evarista write 1 the program must read two values: i (1 <= i <= 5*10^4) (the position of the i-th item to which she wants to change the price) and p (the amount of money that must be increased to the i-th item that is being displayed).
  • When writing 2 the program must read two positions: i(1 <= i <= 5 * 10^4) (the position of the first item from which you want to start adding) and j (1 <= j <= 5 * 10^4) (the position of the last item that you want to add).
PS: As Evarista is a woman of very advanced age, she tends to easily forget the value she must enter to obtain the sum of her articles in a range. Sometimes unknowingly enters an X value (2 <= X <= 20), so Pánfilo asks you that on those occasions if X is an even value you return to Evarista the sum of the items price in a given range, in case X is odd (and X! = 1), "Error" must be printed.

Input specification

Line 1: Two integers separated by a space N and Q (1 <= N <= 5 * 10^4, Q <= 5 * 10^4), the number of items that Evarista sells and the number of operations that are going to be performed on them.
Line 2: Contains P integers separated by a space, the price of the items that Evarista sells (1 <= P <= 1000).
The following Q lines contain the operations that Evarista performs on its articles:
  • 1 i p Add to article i the value of p ( p < 5 * 10^4).
  • (2 <= X <= 20) i j The sum of all the items that are in the range.

;jsessionid=E9DB9B6BEFCB70D65144DEDAF3AF6852
Línea 1: Dos enteros separados por un espacio N y Q (1 <= N<=5*10^4, Q <= 5*10^4), la cantidad de artículos que vende Evarista y la cantidad de operaciones que se van a realizar sobre ellos.
Línea 2: Contiene P enteros separados por un espacio, el precio de los artículos que vende Evarista (1 <= P <= 1000).
Las siguientes Q líneas contienen las operaciones que Evarista realiza sobre sus artículos:
  • 1 i p Adicionar al artículo i el valor de p ( p < 5 * 10^4).
  • (2 <= X <= 20) i j La suma de todos los artículos que se encuentran en el rango.
Line 1: Two integers separated by a space N and Q (1 <= N <= 5 * 10^4, Q <= 5 * 10^4), the number of items that Evarista sells and the number of operations that are going to be performed on them.
Line 2: Contains P integers separated by a space, the price of the items that Evarista sells (1 <= P <= 1000).
The following Q lines contain the operations that Evarista performs on its articles:
  • 1 i p Add to article i the value of p ( p < 5 * 10^4).
  • (2 <= X <= 20) i j The sum of all the items that are in the range.

;jsessionid=E9DB9B6BEFCB70D65144DEDAF3AF6852

Output specification

For each operation carried out, you must show the number of the operation followed by its result. When the transaction is of type 1, you must show the new price of the modified item, if the transaction was of type (2 <= X <= 20) show the total amount of money that Evarista would obtain if you sell all those items, otherwise you must print "Error" without quotes.

Por cada operación realizada debe mostrar el número de la operación más su resultado. Cuando la operación sea de tipo 1 debe mostrar el nuevo precio del artículo modificado, si la operación fue de tipo (2 <= X <= 20) muestre el total de dinero que obtendría Evarista si vende esos artículos, en caso contrario debe devolver "Error".
Line 1: Two integers separated by a space N and Q (1 <= N <= 5 * 10^4, Q <= 5 * 10^4), the number of items that Evarista sells and the number of operations that are going to be performed on them.
Line 2: Contains P integers separated by a space, the price of the items that Evarista sells (1 <= P <= 1000).
The following Q lines contain the operations that Evarista performs on its articles:
  • 1 i p Add to article i the value of p ( p < 5 * 10^4).
  • (2 <= X <= 20) i j The sum of all the items that are in the range.

;jsessionid=E9DB9B6BEFCB70D65144DEDAF3AF6852

Sample input

6 4
7 2 9 4 10 125
1 4 6
3 5 6
2 2 6
1 1 3

Sample output

1 10
Error
2 156
1 10

Hint(s)

http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/

Recommendation

We have carefully selected several similar problems: 3379 | 3166 | 2378 | 2756 | 3419 | 3734