题目:题目链接

思路:比赛中读错了题,题目要求选一个连续区间,却读成了随便选取几个柜台,英语要好好学啊,读懂题就很简单了,扫一遍就出结果了

AC代码:

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> #define FRER() freopen("in.txt", "r", stdin);
#define INF 0x3f3f3f3f using namespace std; const int maxn = + ; vector<int> stand[maxn << ]; int brand[maxn], N, K; void init() {
for(int i = ; i < (N << ); ++i)
stand[i].clear();
memset(brand, , sizeof(brand));
} int solve() {
int st = , ed = , ans = INF, k = , now = ;
while(ed < (N << )) {
for(int i = ; i < stand[ed].size(); ++i) {
++now;
if(brand[stand[ed][i]] == )
++k;
++brand[stand[ed][i]];
}
++ed;
while(k == K && st < ed) {
ans = min(ans, now);
for(int i = ; i < stand[st].size(); ++i) {
--now;
--brand[stand[st][i]];
if(brand[stand[st][i]] == )
--k;
}
++st;
}
}
return ans == INF ? - : ans;
} int main()
{
//FRER()
while(~scanf("%d %d", &N, &K)) {
init();
int n, num;
for(int i = ; i < N; ++i) {
scanf("%d", &n);
for(int j = ; j < n; ++j) {
scanf("%d", &num);
stand[i].push_back(num);
stand[i + N].push_back(num);
}
}
printf("%d\n", solve());
}
return ;
}

最新文章

  1. js中什么时候回考虑用call或者apply
  2. Echarts3
  3. 自定义View(3)关于canas.drawText
  4. js模拟Map对象,实现key---value
  5. PHP拦截器的使用(转)
  6. printf 格式化最常用用法
  7. sql语句-排序后加入序号再运算判断取想要的项
  8. Uva 10550 Combination Lock
  9. angular路由参数说明
  10. Python第二话 初识复杂数据类型(list、dictionary、tuple)
  11. PHPCMS v9.6.0 任意文件上传漏洞分析
  12. linux 上安装图形界面
  13. Unix、Windows、Mac OS、Linux系统故事
  14. Python3调用Hadoop的API
  15. UVA1607-Gates(思维+二分)
  16. python中可变参数和关键字参数总结
  17. twitter ads_campaign management(图示)
  18. 20165215 2017-2018-2 《Java程序设计》第4周学习总结
  19. GraphQL和C#
  20. 安装Ubuntu后一些准备

热门文章

  1. (转)使用参数SQL_SLAVE_SKIP_COUNTER处理mysql slave同步错误讨论
  2. Python网络编程中的服务器架构(负载均衡、单线程、多线程和同步、异步等)
  3. 【Java】 Maven多模块项目上传到Sonar扫描问题合集
  4. JSTORM中IRichBolt与IBasicBolt的区别
  5. 关于rabbitmq的消息路由的同步问题
  6. Appium基础一:Appium概念
  7. Android端WebRTC点对点互连
  8. Android商城开发系列(七)—— 使用RecyclerView展示首页数据
  9. java入门第二章——java编程基础
  10. 《学习CSS布局》学习笔记