【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

类似尺取法。
用set判断这段区间有没有重复的数字。
有的话,就把头节点的那个数字删掉,直到没有为止。

【代码】

/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
/*
一定在这里写完思路再敲代码!!!
*/
#include <bits/stdc++.h>
using namespace std; const int N = 1e6; int n,a[N+10];
set<int> myset; int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int T;
cin >> T;
while (T--){
myset.clear();
cin >> n;
for (int i = 1;i <= n;i++) cin >> a[i];
int l = 1,ma = 1;
myset.insert(a[1]);
for (int i = 2;i <= n;i++){
while(myset.find(a[i])!=myset.end()) myset.erase(a[l++]);
myset.insert(a[i]);
ma = max(ma,i-l+1);
}
cout <<ma<<endl;
}
return 0;
}

最新文章

  1. MySQL存储引擎--MyISAM与InnoDB区别
  2. spring bean的重新加载
  3. freeCodeCamp:Falsy Bouncer
  4. Effective C++ 6.继承与面向对象设计
  5. Python中的正斜杠与反斜杠
  6. 提交App,请求Apple加急审核
  7. phpcms的安装以及简单使用
  8. barmanager工具栏及gridcontrol部分属性设置
  9. macvlan 网络结构分析 - 每天5分钟玩转 Docker 容器技术(56)
  10. ssm整合快速入门程序(三)之Data类型转换器
  11. 【iOS】swift-获取webView的高度
  12. redis测试实践
  13. CF D.Mister B and Astronomers
  14. 自学Python4.9-生成器举例
  15. C#设计模式(3)——抽象工厂模式
  16. 异类查询要求为连接设置ANSI_NULLS和ANSI_WARNINGS选项
  17. Python 计数器
  18. MySQL笔记(4)---表
  19. vscode对Vue文件的html部分格式化失效问题解决办法
  20. Android OpenGL ES和OpenGL一起学(二)------理解Viewport(视口)和坐标系Android OpenGL ES篇(转帖)

热门文章

  1. swift具体解释之八---------------下标脚本
  2. 4.angularJS-指令(directive)
  3. 转:Java读写文件各种方法及性能比较
  4. element-ui表格控件前端分页方法
  5. obdg反汇编破解crackme
  6. Spring MVC源码——Servlet WebApplicationContext
  7. struts.xml配置action没用,任意href自动跳到主页,在action中print没用?????
  8. php将数组或字符串写入文件
  9. Transport Tablespace Set(三) ----transport single tablespace
  10. 使用 Facebook开源动画库 POP 实现真实衰减动画