...
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;
以上是关于...的主要内容,如果未能解决你的问题,请参考以下文章