CodeForces 862A Mahmoud and Ehab and the MEX
来源:互联网 发布:2016年汇川区财政数据 编辑:程序博客网 时间:2024/05/21 22:41
题目链接:http://codeforces.com/contest/862/problem/A
题意:给你一个大小为n的集合,你现在有添加和删除操作,问你要经过多少操作,才能使得这个集合里,最小的没有出现的元素为x
解析:假设给你一个空集合,那么需要的操作数是x,但是如果这个多一个小于x的元素,那么你就不用再添加了,所以操作数-1,如果有x,操作数要+1,因为要删除它
#include <bits/stdc++.h>using namespace std;int main(void){ int n,x,num; scanf("%d %d",&n,&x); int ans = x; for(int i=0;i<n;i++) { scanf("%d",&num); if(num<x) ans--; else if(num==x) ans++; } printf("%d\n",ans); return 0;}
阅读全文
0 0
- codeforces 862A Mahmoud and Ehab and the MEX
- codeforces 862A Mahmoud and Ehab and the MEX
- Codeforces 862A Mahmoud and Ehab and the MEX
- codeforces 862A 之 Mahmoud and Ehab and the MEX
- CodeForces 862A Mahmoud and Ehab and the MEX
- Codeforces Round #435 A. Mahmoud and Ehab and the MEX
- Codeforces Round #435 A. Mahmoud and Ehab and the MEX
- Codeforces --- Mahmoud and Ehab and the MEX
- A. Mahmoud and Ehab and the MEX
- 862A. Mahmoud and Ehab and the MEX
- 862A Mahmoud and Ehab and the MEX (水)
- CF 862A. Mahmoud and Ehab and the MEX
- Codeforces Round #435 (Div. 2) A. Mahmoud and Ehab and the MEX(思路)
- Mahmoud and Ehab and the MEX
- Mahmoud and Ehab and the xor CodeForces
- Mahmoud and Ehab and the bipartiteness CodeForces
- Mahmoud and Ehab and the xor CodeForces
- codeforces Mahmoud and Ehab and the bipartiteness
- 手写体数字识别例程——LeNet-5模型
- ViewPager + Fragment组合实现局部刷新Fragment
- openssl 生成公钥和私钥 window
- Kotlin实现recyclerView列表
- 第七周项目2——建立链队算法库
- CodeForces 862A Mahmoud and Ehab and the MEX
- 【数据结构】Dijkstra求最短路径的图的邻接矩阵的实现
- 在Windows 7 的64位系统上,安装tensorflow 的CPU版本
- 【Android】【LCD】LCD开发常见问题&分析
- 喊着全面吊打iPhoneX, 这就是最贵国产旗舰机华为Mate 10!
- Hibernate与Jpa的关系
- 20171017作业
- Mycat之——多Schema配置
- DP训练 CDOJ1321柱爷的恋爱 [区间dp]