...

Posted repulser

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了...相关的知识,希望对你有一定的参考价值。

include

include

include

include

include

using namespace std;

define LL long long

const LL N = 2e5 + 100;

LL n, k, a[N], tot, ans;
bool vis[N], cnt[N];

inline void open_judge()
freopen ("page.in", "r", stdin);
freopen ("page.out", "w", stdout);

int main()
open_judge();
scanf("%lld%lld",&n,&k);
for(int i = 1 ; i <= n ; i++)
scanf("%lld",&a[i]);
for (int i = 1 ; i <= n ; i++)
if (cnt[a[i]])continue;
else if (tot < k)++ans, ++tot, cnt[a[i]] = true;
else
memset(vis, false,sizeof(vis));
LL pos;
for(int j = i + 1 ; j <= n ; j++)
if (vis[a[j]] || !cnt[a[j]]) continue;
pos = j;
vis[a[j]] = true;

for(int k = 1 ; k <= i ; k++)
if(cnt[a[k]] && ! vis[a[k]])pos = k;

        
        ++ans; 
        cnt[a[pos]] = false; 
        cnt[a[i]] = true; 
    

printf ("%lld\n", ans); 
system("pause");
return 0; 

以上是关于...的主要内容,如果未能解决你的问题,请参考以下文章

Python 操作Redis

python爬虫入门----- 阿里巴巴供应商爬虫

Python词典设置默认值小技巧

《python学习手册(第4版)》pdf

Django settings.py 的media路径设置

Python中的赋值,浅拷贝和深拷贝的区别