Protein Identification
Time limit1sMemory limit512 MB
Given peaks from an imperfect MS2 experiment, find the minimum number of noise peaks over all P/Q proteins whose total mass equals the largest peak.
- Level
Hard9 of 10
- Topics
- Dynamic programming, Greedy, Math, Combinatorics
- Solved
- No attempts yet
Problem
A protein is a chain of amino acids. Its sequence can be studied with tandem mass spectrometry (MS2).
For this problem assume the following simplified setting.
- A protein is a chain of at most amino acids.
- There are only two kinds of amino acid, and .
- has mass daltons and has mass daltons.
The result of an MS2 experiment is a set of real numbers; each number is called a peak. For the true protein, this set contains the mass of every prefix and every suffix of the protein (including the mass of the whole protein) and nothing else. Note that a protein and its reverse produce exactly the same set of prefix and suffix masses.
An experiment on an unknown protein is not perfect, so its result satisfies the following.
- Some prefix or suffix masses may be missing from the set.
- The set may contain peaks that are not the mass of any prefix or suffix of the protein. Such a peak is called a noise peak.
- Every peak is positive.
- The largest peak equals the mass of the whole protein.
- Every peak that does correspond to a prefix or suffix mass is exact.
Given the experimental result, consider every protein made of and (length at most ) whose total mass equals the largest peak. For such a protein, a noise peak is a peak of the input that is not equal to any prefix or suffix mass of that protein. Find the minimum possible number of noise peaks.
Input
The first line contains the number of peaks ().
Each of the next lines contains one peak .
The input always satisfies all of the conditions above, and all peaks are distinct. Each peak is given with at most digits after the decimal point.
Output
Print a single integer: the minimum possible number of noise peaks over all proteins made of and (length at most ) whose total mass equals the largest peak.