3836 - Xana

Created by Luis Manuel Díaz Barón
Added by luismo (2017-06-05)
Limits
Total Time: 12000 MS | Test Time: 2000 MS |Memory: 512 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

You are given a list of N integer elements X1, X2, ... XN and Q queries, each one consisting of two integers L and R (1 ≤ LRN). For each query, you need to determine whether there exists a pair of integers a and b (LabR) such that the sum of all elements from position a to position b is zero.
Dado una lista de N números enteros X1, X2, ... XN y Q preguntas que consisten en dos índices L y R (1 ≤ LRN). Por cada pregunta, necesitas determinar si existe una pareja de índices a y b (LabR) de tal manera que la suma de todos los elementos de la posición a hasta la posición b sea igual a cero.
You are given a list of N integer elements X1, X2, ... XN and Q queries, each one consisting of two integers L and R (1 ≤ LRN). For each query, you need to determine whether there exists a pair of integers a and b (LabR) such that the sum of all elements from position a to position b is zero.

Input specification

In the first line, there are two space separated integers N (1 ≤ N ≤ 105) and Q (1 ≤ Q ≤ 105) indicating the number of elements in the list and the number of queries, respectively.

The next line contains N space separated integers, each one with absolute value at most 109 (|X1| ≤ 109).

Each of the next Q lines contains two space separated integers L and R (1 ≤ LRN), describing a query.

En la primera línea tenemos dos números enteros N (1 ≤ N ≤ 105) y Q (1 ≤ Q ≤ 105) separados por un espacio, los cuales corresponden a la cantidad de elementos en la lista y la cantidad de preguntas a contestar, respectivamente.

Las siguientes N líneas contienen parejas de enteros separados por un espacio; el valor absoluto de cada uno supera no supera a 109 (|X1| ≤ 109).

Cada una de las siguientes Q líneas contiene una pareja de enteros L y R (1 ≤ LRN) separados por un espacio, los cuales describen una pregunta.

In the first line, there are two space separated integers N (1 ≤ N ≤ 105) and Q (1 ≤ Q ≤ 105) indicating the number of elements in the list and the number of queries, respectively.

The next line contains N space separated integers, each one with absolute value at most 109 (|X1| ≤ 109).

Each of the next Q lines contains two space separated integers L and R (1 ≤ LRN), describing a query.

Output specification

For each query, in the same order as given in the input, you should print "YES" if there exists a pair of integers a and b (L ≤ a ≤ b ≤ R) such that the sum of all elements from position a to position b is zero, otherwise print "NO".
Para cada pregunta, en el mismo orden dado de entrada, debes imprimir la palabra "YES" si existe una pareja de enteros a and b (L ≤ a ≤ b ≤ R) de tal manera que la suma de todos los elementos desde la posición a hasta la posición b es cero; de lo contrario, imprima la palabra "NO".

In the first line, there are two space separated integers N (1 ≤ N ≤ 105) and Q (1 ≤ Q ≤ 105) indicating the number of elements in the list and the number of queries, respectively.

The next line contains N space separated integers, each one with absolute value at most 109 (|X1| ≤ 109).

Each of the next Q lines contains two space separated integers L and R (1 ≤ LRN), describing a query.

Sample input

5 3
4 2 -1 1 -1
1 5
2 4
1 3

Sample output

YES
YES
NO

Hint(s)