logo AlgoBeat OnlineJudge
登录 注册

#217676. [ECNA 2023] A Pivotal Question

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Quicksort is a recursive sorting algorithm developed in 1959 by Tony Hoare. One of the major steps in the algorithm is the partition step: given an element in the array (the pivot element), rearrange the elements into the form

where all the values in are and all elements in are .

For example, after an array has been partitioned with pivot element , all values at most appear to its left and all larger values appear to its right. Note that the elements in and are typically not in sorted order and either one of them could be empty.

How a partition is executed and how a pivot element is selected are fascinating questions but are not of interest to us. What we would like you to do is the following: given an array, determine all the values that could be the pivot value assuming the array has been partitioned, or determine that the array has not been partitioned.

输入格式

Input starts with a positive integer denoting the size of the array. Following this are positive integers indicating the values in the array. All values are unique and .

输出格式

Output the number of values in the array that could have served as pivot values to partition the array, followed by the pivot values in the order that they appear in the input. If just output the first 100 of these pivot values. Note that a value of indicates that the array is not partitioned.

样例

样例输入 1

10 1 11 8 13 53 20 63 99 79 94

样例输出 1

3 1 13 63