306443: CF1198A. MP3

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

MP3

题意翻译

# 题目描述 有一种数字化一段录音的常用方式,是记录每一个时刻的强度值。这些非负的强度值就可以代表一段音频 对于一段音频,若有 $K$ 个不同的强度值,那么每一位我们都需要 $k = \lceil\log_2K \rceil$ $\text{bit}$ 来存储 也就是说,为了存储这一段音频,我们需要 $nk$ 个 $\text{bit}$ 为了压缩音频大小,我们们采取如下的方式: 选择两个整数 $l, r(l \leq r)$,对于音频的强度值序列 $v$,将其作一次变换: $$ v_i = \begin{cases} v_i&l \leq v_i \leq r \\ l &v_i < l\\ r &r < v_i \end{cases} $$ 其中第 $2, 3$ 种情况被视作 $v_i$ 这个强度值被更改了 你的任务是对于给定的强度值序列 $a$,找到一组 $l, r$,使得在经过上述压缩后能够被大小为 $I \ \text{bytes} (\text{1bytes = 8 bit})$ 的存储器装下,并最小化被更改的强度值的数量 # 输入输出格式 ## 输入格式 第一行包含两个正整数 $n,I \ (n \leq 4 \cdot 10^5, I \leq 10^8)$,描述了音量总时刻数与存储器大小 第二行包含 $n$ 个正整数 对于第 $i$ 个数,描述了 $a_i$,即时刻 $i$ 的音量强度值 ## 输出格式 输出答案,即在所有的适合存储器大小的压缩方案中,最小的被更改的强度值的数量

题目描述

One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $ n $ non-negative integers. If there are exactly $ K $ distinct values in the array, then we need $ k = \lceil \log_{2} K \rceil $ bits to store each value. It then takes $ nk $ bits to store the whole file. To reduce the memory consumption we need to apply some compression. One common way is to reduce the number of possible intensity values. We choose two integers $ l \le r $ , and after that all intensity values are changed in the following way: if the intensity value is within the range $ [l;r] $ , we don't change it. If it is less than $ l $ , we change it to $ l $ ; if it is greater than $ r $ , we change it to $ r $ . You can see that we lose some low and some high intensities. Your task is to apply this compression in such a way that the file fits onto a disk of size $ I $ bytes, and the number of changed elements in the array is minimal possible. We remind you that $ 1 $ byte contains $ 8 $ bits. $ k = \lceil log_{2} K \rceil $ is the smallest integer such that $ K \le 2^{k} $ . In particular, if $ K = 1 $ , then $ k = 0 $ .

输入输出格式

输入格式


The first line contains two integers $ n $ and $ I $ ( $ 1 \le n \le 4 \cdot 10^{5} $ , $ 1 \le I \le 10^{8} $ ) — the length of the array and the size of the disk in bytes, respectively. The next line contains $ n $ integers $ a_{i} $ ( $ 0 \le a_{i} \le 10^{9} $ ) — the array denoting the sound file.

输出格式


Print a single integer — the minimal possible number of changed elements.

输入输出样例

输入样例 #1

6 1
2 1 2 3 4 3

输出样例 #1

2

输入样例 #2

6 2
2 1 2 3 4 3

输出样例 #2

0

输入样例 #3

6 1
1 1 2 2 3 3

输出样例 #3

2

说明

In the first example we can choose $ l=2, r=3 $ . The array becomes 2 2 2 3 3 3, the number of distinct elements is $ K=2 $ , and the sound file fits onto the disk. Only two values are changed. In the second example the disk is larger, so the initial file fits it and no changes are required. In the third example we have to change both 1s or both 3s.

Input

题意翻译

# 题目描述 有一种数字化一段录音的常用方式,是记录每一个时刻的强度值。这些非负的强度值就可以代表一段音频 对于一段音频,若有 $K$ 个不同的强度值,那么每一位我们都需要 $k = \lceil\log_2K \rceil$ $\text{bit}$ 来存储 也就是说,为了存储这一段音频,我们需要 $nk$ 个 $\text{bit}$ 为了压缩音频大小,我们们采取如下的方式: 选择两个整数 $l, r(l \leq r)$,对于音频的强度值序列 $v$,将其作一次变换: $$ v_i = \begin{cases} v_i&l \leq v_i \leq r \\ l &v_i < l\\ r &r < v_i \end{cases} $$ 其中第 $2, 3$ 种情况被视作 $v_i$ 这个强度值被更改了 你的任务是对于给定的强度值序列 $a$,找到一组 $l, r$,使得在经过上述压缩后能够被大小为 $I \ \text{bytes} (\text{1bytes = 8 bit})$ 的存储器装下,并最小化被更改的强度值的数量 # 输入输出格式 ## 输入格式 第一行包含两个正整数 $n,I \ (n \leq 4 \cdot 10^5, I \leq 10^8)$,描述了音量总时刻数与存储器大小 第二行包含 $n$ 个正整数 对于第 $i$ 个数,描述了 $a_i$,即时刻 $i$ 的音量强度值 ## 输出格式 输出答案,即在所有的适合存储器大小的压缩方案中,最小的被更改的强度值的数量

加入题单

算法标签: