40分求助大佬就1,4,6,7过了
查看原帖
40分求助大佬就1,4,6,7过了
1183967
iLibra2526楼主2024/5/31 23:40

m,n=map(int,input().split())

words=list(map(int,input().split()))

count=0

s=[]*m

for i in words:

if i in s:
    s.remove(i)
    s.insert(0,i)
else:
    if len(s)<m:
        s.insert(0,i)
        count +=1
    else:
        s.pop()
        s.insert(0,i)
        count +=1

print(count)

2024/5/31 23:40
加载中...