题目:题目链接

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

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 ;
}

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. SyntaxHighlighter

    SyntaxHighlighter uses separate syntax files called brushes to define its highlighting functionality ...

  2. springboot 学习笔记(三)

    (三)用jar包启动springboot项目 1.首先需要在pom文件中添加依赖,spring-boot-starter-parent包含有打包的默认配置,如果要修改的话要可以进行重新定义,具体内容参 ...

  3. Spring的七种事务传播机制

    概述 当我们调用一个基于Spring的Service接口方法(如UserService#addUser())时,它将运行于Spring管理的事务环境中,Service接口方法可能会在内部调用其它的Se ...

  4. Dubbo 使用rest协议发布http服务

    演示用GitHub地址:https://github.com/suyin58/dubbo-rest-example 1       Dubbo_rest介绍 Dubbo自2.6.0版本后,合并了dub ...

  5. AngularJS(八):http服务

    本文也同步发表在我的公众号“我的天空” http服务 之前我们的示例都是在本地获取模拟数据,在实际应用中,所有的项目都将不可避免的从后台获取数据,我们都是通过Ajax来实现与服务器的通信.在Angul ...

  6. Python+selenium之下载文件

    一.Firefox文件下载 Web容许我们设置默认的文件下载路劲,文件会自动下载并且存放在指定的目录下. from selenium import webdriver import os fp = w ...

  7. 【TensorFlow入门完全指南】神经网络篇·自动编码机

    自动编码机(Autoencoder)属于非监督学习,不需要对训练样本进行标记.自动编码机(Autoencoder)由三层网络组成,其中输入层神经元数量与输出层神经元数量相等,中间层神经元数量少于输入层 ...

  8. Python:numpy数组转换为json格式

    在python中,如何将一个numpy数组转换为json格式? 这是最近遇到的一个问题,做个笔记. 假设arr为numpy数组,将其转换为json格式: 总体思想是①首先转换为python的list, ...

  9. Berkeley DB (VC6.0 编译环境配置)

    操作系统:winxp VC环境:VC6.0 必需文件:Berkeley DB安装文件(db-.msi) 下载地址:http://www.oracle.com/technology/software/p ...

  10. TIF转JPG

    public void TifToJpg(string tifPath, string tifName) { try { //找到后缀为TIF的图像,如果没有,就catch退出 int len = t ...