V Vector V88097


Statement
 

pdf   zip   main.cc

thehtml

A vector V is a vector that is composed of two parts:

v = x1  ‍ x2  ‍ x3  ‍ x4 … xn  ‍ y1  ‍ y2 ‍ y3 … ym

such that x1xn is ordered in a strictly decreasing manner and y1ym is ordered in a strictly increasing manner. Furthermore, xn > y1. Finally, we have that n,m > 0. That is, neither part is empty.

We need to implement the function int picV(const vector<int>& v) with the following specification:

PRE: v is a vector V and ∣ v ∣ ≥ 3.

POST: The position of y1 in v.

Observation

IMPORTANT: You only need to submit the requested function, and possibly other necessary actions and functions. However, you must keep the type definitions and #includes.

Input

An undetermined number of vectors V with the following format: an integer indicating their size, and then the vector V. Every vector V has a size greater than or equal to 3.

Output

The position within the vector where y1 is.

Sample session
ENTRADA 1:
15
7 6 5 4 3 2 1 2 3 4 5 6 7 8 9

SORTIDA 1:
6



ENTRADA 2:
15
15 14 13 12 11 10 9 8 7 6 5 4 3 4 5

SORTIDA 2:
12



ENTRADA 3:
15
15 14 13 12 11 10 9 8 7 6 5 4 3 2 5

SORTIDA 3:
13



ENTRADA 4:
5
2 1 3 5 7

SORTIDA 4:
1



ENTRADA 5:
10
5 4 3 2 1 6 7 18 29 30

SORTIDA 5:
4
Information
Author
PRO1
Language
English
Translator
Original language
Catalan
Other languages
Catalan Spanish
Official solutions
C++
User solutions
C++