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 ...
随机推荐
- 058 Length of Last Word 最后一个单词的长度
给定一个字符串, 包含大小写字母.空格 ' ',请返回其最后一个单词的长度.如果不存在最后一个单词,请返回 0 .注意事项:一个单词的界定是,由字母组成,但不包含任何的空格.案例:输入: " ...
- WebStorm技巧-集成命令行工具插件
打开菜单项 File -> Settings- 搜索插件 CMD Support,并安装. 重启WebStorm,在你的项目中新建一个Cmd script 文件,命名为build.cmd ...
- ORACLE行转列通用过程(转)
1.使用视图 SQL code? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 create or r ...
- Git、Github和GitLab的区别及与SVN的比较
个人理解: SVN适合领导啊,大家一起在加班,看你进度什么的,git则不必如此,忙完传上来完活. 一.含义: 百度上这样介绍的: Git(读音为/gɪt/.)是一个开源的分布式版本控制系统,可以有效. ...
- PC端和手机端页面的一丢丢区别
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...
- Servlet--HttpServlet
一.Servlet 接口(javax.servlet) 定义: public interface Servlet Implemented by: FacesServlet, Gene ...
- 织梦list/arclist标签调用文章内容
list标签: 1. 进入后台->模型表单-> 频道模型 -> 内容模型管理 -> 修改对应的模型 2. 列表附加字段-填写body 3. 调用时添加“addfields='b ...
- JMeter配置元件作用域
- JavaScript_10_错误
Try...catch... throw <!DOCTYPE html> <html> <head> <title></title> < ...
- 【Python图像特征的音乐序列生成】关于数据库到底在哪里下载
毕竟原网站一个是14年前的一个是16年前的…… 1,http://ifdo.ca/~seymour/nottingham/nottingham.html 这个网站可以下载zip包. 2,https:/ ...