#P2471. Rainfall Trend Verification

    ID: 15742 Type: Default 1000ms 256MiB

Rainfall Trend Verification

Rainfall Trend Verification

In this problem, you are given a sequence of yearly rainfall records. Some years have known rainfall amounts (non‐negative integers) while others are unknown (represented as -1). You will also be given a query in the form of two years, Y and X (with Y < X). We say "Year X is the wettest since Year Y" if and only if for every year Z such that Y < Z < X, the rainfall in year Z is strictly less than the rainfall in year X.

Note that the rainfall for Year Y is not used in the comparison; the condition only applies to the years strictly between Y and X. For example, consider the data for four years (2002, 2003, 2004, 2005) with rainfall amounts 4920, 5901, 2832, and 3890 respectively. We can say "2005 is the wettest since 2003" because the only intermediate year (2004) satisfies 2832 < 3890, but we cannot say "2005 is the wettest since 2002" since 2003 (an intermediate year) has 5901 which is not less than 3890.

Because some years have unknown values, a statement might be definitely true, definitely false, or only possibly true (if there exists an assignment of the unknown values making the statement true as well as one making it false).

The task is to decide, based solely on the known data, whether the statement is definitely true, definitely false, or maybe true.

Additional detail: If there are no intermediate years between Y and X (i.e. X = Y+1), the statement is always considered true.

inputFormat

The input consists of three lines.

1. The first line contains two integers S and N, where S is the starting year and N is the number of consecutive years. Thus, the years are S, S+1, ..., S+N-1.

2. The second line contains N integers. Each integer represents the rainfall in the corresponding year. A value of -1 indicates that the rainfall for that year is unknown; otherwise, it is a non-negative integer.

3. The third line contains two integers Y and X (with S ≤ Y < X ≤ S+N-1), representing the query: "Is Year X the wettest since Year Y?"

outputFormat

Print a single word:

- true if, regardless of how unknown values are assigned, the statement is always true;

- false if, regardless of the assignments of unknowns, the statement cannot hold;

- maybe if the known data does not force a definite answer (i.e. the statement could be made true or false by a suitable assignment of the unknown values).

sample

2002 4
4920 5901 2832 3890
2003 2005
true