1 Star 0 Fork 0

util6/算法刷题c++

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Weekst2.cpp 495 Bytes
一键复制 编辑 原始数据 按行查看 历史
util6 提交于 2022-04-02 21:39 +08:00 . 默认的
/**
* @author 大菜狗
*/
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define pb push_back
#define fi first
#define se second
const int N = 500005, M = 1000005;
int n,k;
int a[N],cnt[M];
int main(){
std::ios::sync_with_stdio(false);
cin>>n>>k;
for(int i = 1; i <=n; i++) {
cin>>a[i];
}
int t = 0;
for(int i = 1,j = 1; i <=n; i++) {
if (cnt[a[i]]==0) t++;
cnt[a[i]]++;
while (t>k){
cnt[a[i]]++;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liuyutaocode/cppCode.git
git@gitee.com:liuyutaocode/cppCode.git
liuyutaocode
cppCode
算法刷题c++
master

搜索帮助