R Vector V84883


Statement
 

pdf   zip   main.cc

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

v=x1x2x3x4xny1y2y3ymv = x_1 ~ x_2 ~ x_3 ~ x_4 \dots x_n ~ y_1 ~ y_2~ y_3 \dots y_m

such that the part x1xnx_1 \dots x_n and the part y1ymy_1 \dots y_m are ordered strictly in increasing order but ym<x1y_m < x_1. We also have that n,m>0n,m > 0. That is, neither part is empty.

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

PRE: vv is a vector R and v3\mid \! v \! \mid \geq 3.

POST: The position of y1y_1 in vv.

Observation

You only need to send the function we ask for and the actions and functions that you define yourself. The rest will be ignored.

Input

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

Output

The position within the vector where y1y_1 is.

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

SORTIDA 1:
5



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

SORTIDA 2:
13



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

SORTIDA 3:
1



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

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