atcoder#ARC147A. [ARC147A] Max Mod Min
[ARC147A] Max Mod Min
Score : points
Problem Statement
You are given a sequence of positive integers: .
You will repeat the following operation until the length of becomes .
- Let be the length of before this operation. Choose integers and such that $\max(\{A_1,A_2,\dots,A_{k}\})=A_i,\min(\{A_1,A_2,\dots,A_{k}\})=A_j$, and . Then, replace with . If becomes at this moment, delete from .
Find the number of operations that you will perform. We can prove that, no matter how you choose in the operations, the total number of operations does not change.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
2 3 6
3
You will perform operations as follows:
- Choose . You get , and delete from . Now you have .
- Choose . You get . Now you have .
- Choose . You get , and delete from . Now you have , and terminate the process because the length of becomes .
6
1232 452 23491 34099 57341 21488
12