Ice cream samples Gym - 101670G 滑动扫描
题目:题目链接
思路:比赛中读错了题,题目要求选一个连续区间,却读成了随便选取几个柜台,英语要好好学啊,读懂题就很简单了,扫一遍就出结果了
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 滑动扫描的更多相关文章
- Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)
题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...
- Ice Cream Tower Gym - 101194D (贪心 + 二分 )
题目链接 : https://cn.vjudge.net/problem/Gym-101194D 题目大意 : 给你n个冰激凌球,让你用这些冰激凌球去垒冰激凌,要求是下面的这一个必须是他上面一个的两倍 ...
- CTU OPEN 2017 Ice cream samples /// 尺取法
题目大意: 给定n k 接下来n行 给定n个摊位的冰淇淋信息 首先给一个t 表示这个摊位有t个冰淇淋 接下来t个数表示对应冰淇淋的品种 走到连续的几个摊位 会买下走过的摊位的所有的冰淇淋 求 要买下所 ...
- Gym 101194D Ice Cream Tower
被一道数位DP折磨得欲仙欲死之后,再做这道题真是如同吃了ice cream一样舒畅啊 #include<bits/stdc++.h> using namespace std; #defin ...
- 2016-2017 ACM-ICPC CHINA-Final Ice Cream Tower 二分+贪心
/** 题目:2016-2017 ACM-ICPC CHINA-Final Ice Cream Tower 链接:http://codeforces.com/gym/101194 题意:给n个木块,堆 ...
- HackerRank Ice Cream Parlor
传送门 Ice Cream Parlor Authored by dheeraj on Mar 21 2013 Problem Statement Sunny and Johnny together ...
- 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 ...
- 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 ...
- Ice Cream Tower
2017-08-18 21:53:38 writer:pprp 题意如下: Problem D. Ice Cream Tower Input file: Standard Input Output f ...
随机推荐
- (转)通过MySQL复制线程SQL_Thread加快增量恢复binlog
数据回档常常是使用全量备份+binlog增量实现的.而数据量很大的情况下,增量恢复binlog一直是一个苦恼的问题,因为恢复binlog速度十分慢,并且容易出错. 恢复binlog文件一般有两种方法: ...
- windows环境下memcache配置方法 详细篇
将memcache服务器安装包解压到C:\memcached文件夹后,使用cmd命令窗口安装. 1>开始>运行:CMD(确定) 2>cd C:\memcached(回车) 3> ...
- ajax取到数据后如何拿到data.data中的属性值
今天遇到的ajax取到数据后如何拿到data.data中的属性值的问题 比如拿到了数据 我要取出data中的name 题外话:当然取名最好别取什么奇怪的xiaobi
- Date 对象 时间格式注意事项
Date 对象,是操作日期和时间的对象. Date 为内置的构造函数, 通过 new Date () 来获取当前本地日期与时间 const time = new Date console.log(ti ...
- Yii2 的快速配置 api 服务 yii2-fast-api
yii2-fast-api yii2-fast-api是一个Yii2框架的扩展,用于配置完善Yii2,以实现api的快速开发. 此扩展默认的场景是APP的后端接口开发,因此偏向于实用主义,并未完全采用 ...
- Jenkins系列——使用SonarQube进行代码质量检查
1.目标 之前已经写过一篇关于Jenkins和SonarQube的一篇博客<jenkins集成sonar>,本文在参考前文的基础上,做了详细的补充. 使用SonarQube进行代码质量检查 ...
- ApexSQL Log中的Redo Script跟原始SQL不一致问题
最近遇到一个误更新数据的问题,使用ApexSQL Log做挖掘事务日志的时候,发现ApexSQL Log生成的Redo Script跟原始SQL是有区别的.它们并不是完全一致的.只是逻辑上等价而已.如 ...
- Maven 中maven-assembly-plugin插件的使用笔记 SpringBoot环境
首先创建一个多模块的SpringBoot项目 项目结构 父pom的内容如下: <?xml version="1.0" encoding="UTF-8"?& ...
- 洛谷 P2827 蚯蚓
题目描述 本题中,我们将用符号\lfloor c \rfloor⌊c⌋表示对c向下取整,例如:\lfloor 3.0 \rfloor= \lfloor 3.1 \rfloor=\lfloor 3.9 ...
- 【Python图像特征的音乐序列生成】关于音乐生成的思路转变
在前几天的讨论会上,有师兄指出原来的方法实在是很难训练,所以我改进了音乐生成的思路. 首先,我用LSTM生成的一定是一段音乐的序列化表达,那么我就可以用成型的一些数据集去训练LSTM.为了避免生成的音 ...