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 ...
随机推荐
- Joda-Time 的 DateTimeFormat 问题
在开发过程中遇到的问题是,当我使用,如下的代码时,会报异常 :"Exception in thread "main" org.joda.time.IllegalField ...
- (转)nginx域名访问的白名单配置梳理
nginx域名访问的白名单配置梳理 原文:http://www.cnblogs.com/kevingrace/p/6086652.html 在日常运维工作中,会碰到这样的需求:设置网站访问只对某些ip ...
- 算法导论课后习题解答 第一部分 练习1.1-1->1.1-5
很高兴能和大家一起共同学习算法导论这本书.笔者将在业余时间把算法导论后面的题解以博文的形式展现出来希望能得到大家的支持谢谢.如果有可能我会做一些教学视频免费的供大家观看. 练习题选自算法导论中文第三版 ...
- undefined is not a function
具体报错 TypeError: c:\Users\Administrator\WebstormProjects\blogtest\views\index.ejs:1 >> 1| <% ...
- Hybrid app(cordova) 环境配置记录
node版本管理 NVM 安装过程 由于最新版 node 不兼容部分功能,所以需要安装 nvm 切换 node 版本 在 https://github.com/coreybutler/nvm-wind ...
- 【转】如何学习Javascript
首先要说明的是,咱现在不是高手,最多还是一个半桶水,算是入了JS的门. 谈不上经验,都是一些教训. 这个时候有人要说,“靠,你丫半桶水,凭啥教我们”.您先别急着骂,先听我说. 你叫一个大学生去教小学数 ...
- Spring Cloud--Feign服务调用组件的使用实例
引入依赖: 启动类上添加@EnableFeignClients注解: 写调用接口: 直接@Autowired注入服务调用接口: 底层使用了动态代理,对接口进行了实现. 并且封装了RestTemplat ...
- AD 域复制FRS 迁移到DFSR
假设您尝试将在先前版本的Windows Server上运行的某个Active Directory域控制器(DC)升级到Windows Server 2019. 您可能会看到以下错误: “副本验证失败. ...
- openfire4.0.2源码 使用 IntelliJ IDEA 搭建开发环境
从官网下载压缩包,解压,直接打开build目录下的project 打开后, 相关的设置 fix直接修复或者下载 设置 设置每个插件目录下的java目录为source 编译openfire和plugin ...
- processing制作动态山水背景
效果代码 float theta, step; int num=5, frames = 1200; Layer[] layers = new Layer[num]; // void setup() { ...