读入可以不需要存入数组

#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

//const int maxn=;

using namespace std;

int t;

int n;

int main()
{
scanf("%d",&t);
while(t--){
map<int, int> m;
scanf("%d",&n);
int ans = -inf;
int cnt = ;
int imax = ;
int x;
for(int i = ; i <= n; ++i){
scanf("%d",&x);
if(!m[x]){
++cnt;
} else {
ans = max(ans, cnt);
imax = max(imax, m[x] + );
cnt = i - imax + ;
}
m[x] = i;
}
ans = max(ans, cnt);
printf("%d\n",ans);
}
return ;
}

最新文章

  1. JSP里面ajax不能返回后台传出的值得问题。。。。
  2. 山东省选 郁闷的小J
  3. ASP.NET MVC利用ajax把action的JavaScript注册到页面并执行
  4. Windows Server 2012学习文档
  5. 【原】NGUI中的UIRoot脚本功能
  6. demo_06Canvas
  7. webform的三级联动
  8. sqlserver 批量删除相同前缀名的表
  9. Eclipse常见操作
  10. 《 iPhone X ARKit Face Tracking 》
  11. Jetty添加Filter过滤器
  12. 由html,body{height:100%}引发的对html和body的思考
  13. IDictionary使用/声明
  14. intellij idea创建maven项目
  15. OpenAuth.Net.landv分支之旅开始制作CRM系统
  16. CodeForces - 455D
  17. 铁板纹理 Base Shape
  18. pyautogui_pdf内容提取到excel内_3
  19. Windows和Mac上NodeJS和Express的安装
  20. Redis缓存机制一为什么要用Redis

热门文章

  1. html5--1.20 课程小结与若干点补充
  2. 分享知识-快乐自己:oracle12c创建用户提示ORA-65096:公用用户名或角色无效
  3. Python 连接Oracle数据库
  4. AtCoder Grand Contest #026 B - rng_10s
  5. ACM学习历程—HDU1716 排列2(dfs &amp;&amp; set容器)
  6. ACM学习历程——hihoCoder挑战赛10A 01串(策略)
  7. Mysql源码学习——源码目录结构
  8. 获取iOS应用中当前处于Activity状态的ViewController
  9. java去任意范围的随机数
  10. editplus怎么在前后插入字符