题目:题目链接

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

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. swjtu oj Paint Box 第二类斯特林数

    http://swjtuoj.cn/problem/2382/ 题目的难点在于,用k种颜色,去染n个盒子,并且一定要用完这k种颜色,并且相邻的格子不能有相同的颜色, 打了个表发现,这个数是s(n, k ...

  2. Codeforces Round #375 (Div. 2) D. Lakes in Berland 并查集

    http://codeforces.com/contest/723/problem/D 这题是只能把小河填了,题目那里有写,其实如果读懂题这题是挺简单的,预处理出每一块的大小,排好序,从小到大填就行了 ...

  3. (转)io各层次性能汇总及运行速度对比

    io各层次性能汇总:以上图片可以清晰的解释io的运行效率 守护进程:持续保持运行着的程序 进程:放在内存中运行的程序 程序:代码文件,php,java

  4. autofac 注入生命周期

    创建实例方法 1.InstancePerDependency 对每一个依赖或每一次调用创建一个新的唯一的实例.这也是默认的创建实例的方式. 官方文档解释:Configure the component ...

  5. 使用 h5 新特性,轻松监听任何 App 自带返回键

    var hiddenProperty = 'hidden' in document ? 'hidden' : 'webkitHidden' in document ? 'webkitHidden' : ...

  6. 常用的 HTML 头部标签

    曾几何时,我们已经不再手写 HTML 标签.Emmet.Markdown 等工具让我们「健步如飞」,但是我们真的了解这些标签了吗? 基本标签 使用 HTML5 doctype,不区分大小写. < ...

  7. H5的storage(sessionstorage&localStorage)简单存储删除

    众所周知,H5的storage有sessionstorage&localStorage,其中他们的共同特点是API相同 下面直接上代码,storage中的存储与删除: <!DOCTYPE ...

  8. Viewcontroller基类

    #import <UIKit/UIKit.h> #import "YQZMutableArray.h" @interface YQZViewController : U ...

  9. ArcSDE 10.1 For Windows 创建空间数据库与常见错误_SQL Server

    本文是2013年时候参加ESRI竞赛,创建ArcSDE 10.1 for SQL Server时候出问题了,因此写了该文档. 由于一直忙于学习,忘了发布.今天一师弟也遇到同样问题,为此我觉得可能有不少 ...

  10. python中的uuid4

    Help on function uuid4 in module uuid: uuid4()    Generate a random UUID.