DMOPC '15 Contest 4 P4 - Great Sequence
View as PDFLuke (perhaps Skywalker) is a passionate computer science student. He receives as homework the following task:
Given a sequence of
integers, determine if the subsequence from
to
inclusive is a Great Sequence. A Great Sequence is a sequence whose sum is strictly greater than
.
Luke thought this is too easy, so he has thought up a new challenge: he'd like to know if a subsequence is an Amazing Sequence. An Amazing Sequence is a Great Sequence in which the integers  and 
 appear. Given his original sequence, he'd like to answer 
 queries, determining if a subsequence is an Amazing Sequence.
Constraints
For all subtasks:
Subtask 1 [30%]
Subtask 2 [70%]
Input Specification
The first line of input will contain the space-separated integers , 
 and 
.
The second line of input will contain 
 space-separated integers representing the sequence.
For the last 
 lines, line 
 will contain query 
 in the format 
, 
, 
 and 
.
Output Specification
For each query, print Yes if the subsequence is an Amazing Sequence, No otherwise.
Sample Input
5 6 3
1 3 4 5 6
3 6 2 5
1 4 1 4
5 6 1 3
Sample Output
Yes
Yes
No
Comments
Dropped time limit to 0.2s to kill vectorized cheese.
What is wrong with my program? Second subtask passes