题目:题目链接

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

AC代码:

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <cstring>
  7. #include <vector>
  8. #include <string>
  9. #include <queue>
  10. #include <map>
  11. #include <set>
  12.  
  13. #define FRER() freopen("in.txt", "r", stdin);
  14. #define INF 0x3f3f3f3f
  15.  
  16. using namespace std;
  17.  
  18. const int maxn = + ;
  19.  
  20. vector<int> stand[maxn << ];
  21.  
  22. int brand[maxn], N, K;
  23.  
  24. void init() {
  25. for(int i = ; i < (N << ); ++i)
  26. stand[i].clear();
  27. memset(brand, , sizeof(brand));
  28. }
  29.  
  30. int solve() {
  31. int st = , ed = , ans = INF, k = , now = ;
  32. while(ed < (N << )) {
  33. for(int i = ; i < stand[ed].size(); ++i) {
  34. ++now;
  35. if(brand[stand[ed][i]] == )
  36. ++k;
  37. ++brand[stand[ed][i]];
  38. }
  39. ++ed;
  40. while(k == K && st < ed) {
  41. ans = min(ans, now);
  42. for(int i = ; i < stand[st].size(); ++i) {
  43. --now;
  44. --brand[stand[st][i]];
  45. if(brand[stand[st][i]] == )
  46. --k;
  47. }
  48. ++st;
  49. }
  50. }
  51. return ans == INF ? - : ans;
  52. }
  53.  
  54. int main()
  55. {
  56. //FRER()
  57. while(~scanf("%d %d", &N, &K)) {
  58. init();
  59. int n, num;
  60. for(int i = ; i < N; ++i) {
  61. scanf("%d", &n);
  62. for(int j = ; j < n; ++j) {
  63. scanf("%d", &num);
  64. stand[i].push_back(num);
  65. stand[i + N].push_back(num);
  66. }
  67. }
  68. printf("%d\n", solve());
  69. }
  70. return ;
  71. }

Ice cream samples Gym - 101670G 滑动扫描的更多相关文章

  1. Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)

    题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...

  2. Ice Cream Tower Gym - 101194D (贪心 + 二分 )

    题目链接 : https://cn.vjudge.net/problem/Gym-101194D 题目大意 : 给你n个冰激凌球,让你用这些冰激凌球去垒冰激凌,要求是下面的这一个必须是他上面一个的两倍 ...

  3. CTU OPEN 2017 Ice cream samples /// 尺取法

    题目大意: 给定n k 接下来n行 给定n个摊位的冰淇淋信息 首先给一个t 表示这个摊位有t个冰淇淋 接下来t个数表示对应冰淇淋的品种 走到连续的几个摊位 会买下走过的摊位的所有的冰淇淋 求 要买下所 ...

  4. Gym 101194D Ice Cream Tower

    被一道数位DP折磨得欲仙欲死之后,再做这道题真是如同吃了ice cream一样舒畅啊 #include<bits/stdc++.h> using namespace std; #defin ...

  5. 2016-2017 ACM-ICPC CHINA-Final Ice Cream Tower 二分+贪心

    /** 题目:2016-2017 ACM-ICPC CHINA-Final Ice Cream Tower 链接:http://codeforces.com/gym/101194 题意:给n个木块,堆 ...

  6. HackerRank Ice Cream Parlor

    传送门 Ice Cream Parlor Authored by dheeraj on Mar 21 2013 Problem Statement Sunny and Johnny together ...

  7. How to Implement Bluetooth Low Energy (BLE) in Ice Cream Sandwich

    ShareThis - By Vikas Verma Bluetooth low energy (BLE) is a feature of Bluetooth 4.0 wireless radio t ...

  8. Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题

    A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...

  9. Ice Cream Tower

    2017-08-18 21:53:38 writer:pprp 题意如下: Problem D. Ice Cream Tower Input file: Standard Input Output f ...

随机推荐

  1. Joda-Time 的 DateTimeFormat 问题

    在开发过程中遇到的问题是,当我使用,如下的代码时,会报异常 :"Exception in thread "main" org.joda.time.IllegalField ...

  2. (转)nginx域名访问的白名单配置梳理

    nginx域名访问的白名单配置梳理 原文:http://www.cnblogs.com/kevingrace/p/6086652.html 在日常运维工作中,会碰到这样的需求:设置网站访问只对某些ip ...

  3. 算法导论课后习题解答 第一部分 练习1.1-1->1.1-5

    很高兴能和大家一起共同学习算法导论这本书.笔者将在业余时间把算法导论后面的题解以博文的形式展现出来希望能得到大家的支持谢谢.如果有可能我会做一些教学视频免费的供大家观看. 练习题选自算法导论中文第三版 ...

  4. undefined is not a function

    具体报错 TypeError: c:\Users\Administrator\WebstormProjects\blogtest\views\index.ejs:1 >> 1| <% ...

  5. Hybrid app(cordova) 环境配置记录

    node版本管理 NVM 安装过程 由于最新版 node 不兼容部分功能,所以需要安装 nvm 切换 node 版本 在 https://github.com/coreybutler/nvm-wind ...

  6. 【转】如何学习Javascript

    首先要说明的是,咱现在不是高手,最多还是一个半桶水,算是入了JS的门. 谈不上经验,都是一些教训. 这个时候有人要说,“靠,你丫半桶水,凭啥教我们”.您先别急着骂,先听我说. 你叫一个大学生去教小学数 ...

  7. Spring Cloud--Feign服务调用组件的使用实例

    引入依赖: 启动类上添加@EnableFeignClients注解: 写调用接口: 直接@Autowired注入服务调用接口: 底层使用了动态代理,对接口进行了实现. 并且封装了RestTemplat ...

  8. AD 域复制FRS 迁移到DFSR

    假设您尝试将在先前版本的Windows Server上运行的某个Active Directory域控制器(DC)升级到Windows Server 2019. 您可能会看到以下错误: “副本验证失败. ...

  9. openfire4.0.2源码 使用 IntelliJ IDEA 搭建开发环境

    从官网下载压缩包,解压,直接打开build目录下的project 打开后, 相关的设置 fix直接修复或者下载 设置 设置每个插件目录下的java目录为source 编译openfire和plugin ...

  10. processing制作动态山水背景

    效果代码 float theta, step; int num=5, frames = 1200; Layer[] layers = new Layer[num]; // void setup() { ...