杭电ACM比赛的一道题目,

学习 时间:2026-03-30 15:58:07 阅读:9396
杭电ACM比赛的一道题目,A.Shooshuns and SequenceTime Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)Total Submission(s) :130 Accepted Submission(s) :34Problem DescriptionOne day shooshuns found a sequence of n integers,written on a blackboard.The shooshuns can perform one operation with it,the operation consists of two steps:1 Find the number that goes k-th in the current sequence and add the same number to the end of the sequence;2 Delete the first number of the current sequence.The shooshuns wonder after how many operations all numbers on the board will be the same and whether all numbers will ever be the same.InputThe first line contains two space-separated integers n and k (1≤k≤n≤105).The second line contains n space-separated integers:a1,a2,...,an (1≤ai≤105) the sequence that the shooshuns found.OutputPrint the minimum number of operations,required for all numbers on the blackboard to become the same.If it is impossible to achieve,print -1.Sample Input3 23 1 13 13 1 1Sample Output1-1SourceCodeforces我想知道怎么去确定一个最大的操作次数,若大于这个次数就判断为一直不相等,然后输出-1?

最佳回答

多情的发箍

大方的巨人

2026-03-30 15:58:07

经过刚才的讨论,大家都学习到了。希望你在ACM的道路上取得长足进步。

最新回答共有2条回答

  • 虚幻的柚子
    回复
    2026-03-30 15:58:07

    经过刚才的讨论,大家都学习到了。希望你在ACM的道路上取得长足进步。

上一篇 这两到题的验算怎么算?要有竖式哦!

下一篇 “hao”草的“hao”字怎么写!