F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Swap

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/262144 K (Java/Others)
Total Submission(s): 62    Accepted Submission(s): 9


Problem Description
You are given a sequence of length $N$, and there is also a number $H$ in your hands.

In each step, you can swap the number in your hands with one of the numbers in the sequence.

Now you need to find the minimum steps to make the sequence in non-decreasing order.
 

Input
There are multiple test cases.

For each test case, the first line contains two integers $N$ and $H$, denoting the length of the sequence and the number in your hands initially.

The second line contains $N$ integers $A_1,A_2,\ldots,A_N$, denoting the initial sequence.

$1\leq H,A_i \leq 10^9$. And the sum of $N$ of all test cases is not larger than $300000$.

 

Output
For each test case, print an integer in one line, denoting your answer.
 

Sample Input
4 3 1 4 2 5 4 3 1 2 5 4 6 2 2 3 4 2 3 4 6 2 3 4 5 3 4 5
 

Sample Output
2 1 3 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 05:13:49, Gzip enabled