report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Consecutive integers - MarisaOJ: Marisa Online Judge

Consecutive integers

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array $A$ of $n$ integers. Find the minimum number of numbers you need to replace to make $A$ consist of only consecutive integers. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the minimum number of integers you have to replace. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le 10^9$. ### Example Input: ``` 3 4 10 5 ``` Output: ``` 1 ``` Note: Replace $10$ with $6$.
Introduction to Binary Search
Binary search
Binary search 2
Binary search 3
Large subarray
Count query
Counting pairs
The k-th candy
Triangle edges
Hamming number
Consecutive integers
Gnimmah distance
Subarray
Topic
Sorting
Binary search
Greedy
Rating 1300
Solution (1) Solution