Toggle navigation
HUSTOJ
F.A.Qs
ProblemSet
Source/Category
Status
Ranklist
Contest
Login
Language
中文
ئۇيغۇرچە
English
فارسی
ไทย
한국어
Problem2362--Melody
2362: Melody
[Creator :
]
Time Limit :
1.000
sec
Memory Limit :
128 MB
Submit
Solved: 6
Submit Num: 8
Statistics
Description
你的朋友梅洛迪(Melody)创作了一首歌曲。梅洛迪的歌曲由 N 个音符组成,其中每个音符用 1 到 K 之间的一个整数表示。N 始终是 3 的倍数。
你恰好对现代流行音乐的趋势非常了解,并且知道一首歌曲好听,当且仅当它由三个音符组成的相同序列不断重复,直至结束。
例如,以下歌曲是好听的:
1, 2, 3, 1, 2, 3, 1, 2, 3(因为 1, 2, 3 不断重复)
6, 4, 4, 6, 4, 4(因为 6, 4, 4 不断重复)
8, 8, 8, 8, 8, 8(因为 8, 8, 8 不断重复)
6, 2, 6(因为 6, 2, 6 不断重复)。
以下歌曲不好听:
1, 2, 3, 4, 5, 6
8, 8, 8, 8, 8, 4
1, 2, 3, 1, 3, 2, 1, 2, 3
2, 2, 5, 5, 2, 2
听了你的建议后,梅洛迪希望改变(但不添加或删除)她歌曲中的部分或全部音符,使歌曲好听。
她最少需要改变多少个音符,才能让她的歌曲好听?
Sample Input
Copy
6 4 1 2 3 4 3 3
Sample Output
Copy
2
HINT
Explanation
In the sample input, the song 1, 2, 3, 4, 3, 3 could be made into the nice song 1, 2, 3, 1, 2, 3.
This requires 2 notes (those in the 4th and 5th positions) to be changed, which is the fewest possible.
Source/Category
AIO
桶