1

绝对半径2051

http://www.nowcoder.com/questionTerminal/089ef989a41f457d9d404de17f411eb6

include<bits/stdc++.h>

using namespace std;
typedef long long ll;
int a[10000000];
vector<int> V[100005];
map<ll, ll> tp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
for(int i = 1; i <= n; i++)
{
cin >> a[i];
}
int l = 1;
int r = 0;
ll ans = 0;
while(l <= n)
{
while(r <= n && r - l + 1 - tp[a[l]] <= k)
{
r++;
a[r];
tp[a[r]]++;
}
ans = max(ans, tp[a[l]]);
while(l <= n && a[l] == a[l + 1])
{
tp[a[l]]--;
l++;
}
tp[a[l]]--;
l++;
}
cout << ans << "\n";
return 0;
}</int>

全部评论

相关推荐

WhiteAlbum...:学院本2中大厂垂直实习➕acm比赛 秋招0面试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务