RGPC '17 P2 - Cubes are Life

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type

Because Gabriel got an early offer from UOIT, his overjoyed parents gave him a lot of Rubik's Cubes as a reward. However, he soon developed Carpal Tunnel Syndrome, and now has to sell some of his cubes at half of their original price to pay for his medical bills.

Gabriel is a very unique person; the N cubes that he got each have a distinct value Vi, and are placed in a straight line. He wants to know if he has a total of at least M dollars after he sells all of his cubes inclusively between the one valued at Va and the one valued at Vb (in the line). He specifically wants to ask Q questions in the form (Va,Vb) to know if he has enough money after selling all of the cubes in that range. Both cubes are guaranteed to exist in the sequence.

Note: it may be helpful to use unsigned 64-bit variables (e.g. unsigned long long in C++).

Constraints

Subtask 1 [10%]
  • 1N,Q100
  • 1M,V1000
Subtask 2 [90%]
  • 1N,Q100000
  • 1M10000000
  • 1V1000000

Input Specification

The first line of input will consist of 3 space-separated integers N, M, and Q. The next line will contain N space-separated integers, where the ith integer represents the Vith value. For the next Q lines, each line will contain 2 space separated integers Va and Vb.

Output Specification

For each question, output Enough if Gabriel can afford his bills or Not enough if he cannot.

Sample Input

Copy
5 10 2
10 1 4 3 7
1 3
10 7

Sample Output

Copy
Not enough
Enough

Comments


  • 2
    moladan123  commented on Feb. 18, 2017, 3:42 a.m.

    This problem is extremely similar to DMOPC '14 Contest 2 P4 - Deforestation. Just for the record.


    • 3
      Dankat  commented on Feb. 18, 2017, 3:56 a.m.

      It's a coincidence and there is a slight difference.


  • -1
    jimgao  commented on Feb. 13, 2017, 7:14 p.m.

    Are the prices multiples of 2?


    • 0
      chenj  commented on Feb. 13, 2017, 9:50 p.m.

      Not necessarily. If the total price after halving isn't exactly M or greater, then it's Not enough.