CF999A Mishka and Contest 题解
Content
能力值为 \(k\) 的小 M 参加一次考试,考试一共有 \(n\) 道题目,每道题目的难度为 \(a_i\)。小 M 会选择两头中的一道难度不超过他的能力值题目去做,每做完一道,这道题目会在题单中消失,序列长度减 \(1\)。求他按照这种方式最多能够做多少道题目。
数据范围:\(1\leqslant n,k,a_i\leqslant100\)。
Solution
从两头开始往中间遍历,哪一头的题目难度大于 \(k\),哪一头就结束扫描,得到最终能做的两头的位置 \(l,r\),答案就是 \(n-r+l+1\)。
Code
int n, k, a[200007], l, r, ans;
int main() {
getint(n), getint(k); l = 0, r = n + 1;
_for(i, 1, n) getint(a[i]);
while(1) {
if(a[l + 1] > k || l == n) break;
++l;
}
while(1) {
if(a[r - 1] > k || r - 1 == l) break;
--r;
}
writeint(ans = (n - (r - l - 1)));
return 0;
}
CF999A Mishka and Contest 题解的更多相关文章
- Mishka and Contest(模拟水题)
Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...
- 坑爹CF April Fools Day Contest题解
H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show som ...
- The 2013 South America/Brazil Regional Contest 题解
A: UVALive 6525 cid=61196#problem/A" style="color:blue; text-decoration:none">Atta ...
- 2015 Syrian Private Universities Collegiate Programming Contest 题解
题目在这里>_< 发现这场比赛在网上没有完整的题解,甚至连题目代码都没人贴出来(大概是因为题目太水了吧...).所以宝宝就来写个题解,也就当作成长记录了233333 A. Window 题 ...
- floyd的魔改应用——洛谷P2419 [USACO08JAN]牛大赛Cow Contest 题解
想找原题请点击这里:传送门 原题: 题目背景 [Usaco2008 Jan] 题目描述 N ( ≤ N ≤ ) cows, conveniently numbered ..N, are partici ...
- 2014-2015 ACM-ICPC, NEERC, Southern Subregional Contest 题解(PART)(9/13)
$$2014-2015\ ACM-ICPC,\ NEERC,\ Southern\ Subregional\ Contest$$ A Nasta Rabbara B Colored Blankets ...
- BNUOJ48605International Collegiate Routing Contest 题解
题目大意: 给你一些子网,求它们在整个网段的补集. 思路: 将子网转换成二进制建一棵Trie,直接DFS搜到没有了就记下来输出.注意:所给的子网会有交集,若搜到结尾就不向下搜了. 代码: #inclu ...
- 2015 ACM Amman Collegiate Programming Contest 题解
[题目链接] A - Who Is The Winner 模拟. #include <bits/stdc++.h> using namespace std; int T; int n; s ...
- 2013-2014 ACM-ICPC Brazil Subregional Programming Contest 题解
[题目链接] 这场比赛题面英文都好长... ... A - Zero or One 模拟. #include <bits/stdc++.h> using namespace std; in ...
随机推荐
- Hardware assisted virtualization and data execution protection must be enabled in the BIOS. See https://docs.docker.com/docker-for-windows/troubleshoot/#virtualization
解决办法:先关闭 Hyper-V ,然后重新开启 Hyper-V 即可! 来自:https://zhuanlan.zhihu.com/p/51939654
- [AGC002D] Stamp Rally
确实有想到重构树,不过没有继续下去的思路. 可能是对重构树的性质不太懂. 这种题目我们可以二分答案,考虑怎么\(check\)呢,整体二分+并查集,建出重构树,找去第一个小于这个数的方点,查询他的子树 ...
- Codeforces 547E - Mike and Friends(AC 自动机+树状数组)
题面传送门 好久每做过 AC 自动机的题了--做几个题回忆一下罢 AC 自动机能够解决多串匹配问题,注意是匹配,碰到前后缀的问题那多半不在 AC 自动机能解决的范围内. 在初学 AC 自动机的时候相信 ...
- 1D RKDG to shallow water equations
RKDG to shallow water equations 1.Governing Equations \[\frac{\partial U}{\partial t} + \frac{\parti ...
- 【Proteogenomis】工具评述
2015年的综述文章,marker一下,供以后比较试用.蛋白质基因组学研究中的质谱仪与生物信息学方法. 针对蛋白质基因组学的分析研究,总结了质谱仪和蛋白质基因组学流程分析软件的选择,重点评述了常用的生 ...
- LightningChart JS v.3.3.0全新版本现已发布!
LightningChart JS v.3.3.0已经发布啦!!! 欢迎了解更多关于最新的性能改进.新的用户界面功能和新的图表类型的信息! WebGL兼容性和新的UI功能 WebGL是Lightnin ...
- 【模板】有源汇有上下界最大流(网络流)/ZOJ3229
先导知识 无源汇有上下界可行流 题目链接 https://vjudge.net/problem/ZOJ-3229 https://www.luogu.com.cn/problem/P5192 (有改动 ...
- C语言中的指针与整数相加的值计算
以下分三种情况: 1. 指针 + 整数值 2. 整数 + 整数 3. 指针强制转换为另一个类型后(指针或者是整数) + 整数 测试例子: 1 struct AAA{ int a; char b[ ...
- 学习java 7.16
学习内容: 线程安全的类 Lock锁 生产者消费者模式 Object类的等待唤醒方法 明天内容: 网络编程 通信程序 遇到问题: 无
- day14搭建博客系统项目
day14搭建博客系统项目 1.下载代码包 [root@web02 opt]# git clone https://gitee.com/lylinux/DjangoBlog.git 2.使用pid安装 ...