Scanner in = new Scanner(System.in); int n = in.nextInt(); int M = in.nextInt(); int []temp = new int[n+1]; for(int i =0;i<M;i++){ int curd = in.nextInt(); temp[curd] =1;//1 标记死亡 } int k = in.nextInt(); int l = 1,r=1,curd=0,res = 0; while (r<=n){ if(temp[r]==1){ curd++; while (curd>k){ if(temp[l]==1) curd--; l++; } } res = Math.max(r-l+1,res); r++; } System.out.println(res);
点赞 评论

相关推荐

11-16 01:13
宜春学院 Java
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务