862A. Mahmoud and Ehab and the MEX
来源:互联网 发布:流体力学分析软件 编辑:程序博客网 时间:2024/06/02 00:32
http://codeforces.com/problemset/problem/862/A
分三种情况讨论 x<t[0],x=t[0],x>t[0];
#include <bits/stdc++.h>using namespace std;int main(){ int n,x; cin>>n>>x; int t[n]; for(int i=0;i<n;i++) cin>>t[i]; sort(t,t+n); if(x<t[0]) { if(x==0) cout<<0; else cout<<x; } if(x==t[0]) { if(x==0) cout<<1; else cout<<x+1; } if(x>t[0]) { int fla=0; for(int i=0;i<n;i++) { if(t[i]==x) fla=1; } if(x<t[n-1]&&fla==0)//在中间五相等 { for(int i=0;i<n;i++) { if(t[i]<x&&t[i+1]>x) { cout<<x-i-1; break; } } } if(x>t[n-1]) { cout<<x-n; } if(x<=t[n-1]&&fla==1) { for(int i=0;i<n;i++) { if(t[i]==x) { cout<<x-i+1; break; } } } } return 0;}
阅读全文
0 0
- A. 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
- 862A. Mahmoud and Ehab and the MEX
- 862A Mahmoud and Ehab and the MEX (水)
- CF 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
- Mahmoud and Ehab and the MEX
- Codeforces --- Mahmoud and Ehab and the MEX
- Codeforces Round #435 (Div. 2) A. Mahmoud and Ehab and the MEX(思路)
- Codeforces Round #435 (Div. 2) 之Mahmoud and Ehab and the MEX
- CF 862C Mahmoud and Ehab and the xor 构造
- Codeforces 862C. Mahmoud and Ehab and the xor
- codeforces 862B B. Mahmoud and Ehab and the bipartiteness
- JavaScript深入学习[1]
- vue-cli 路由嵌套
- 第一篇:对jni和NDK的认识
- java
- HDU 1816 Get Luffy Out *(2-SAT+二分)
- 862A. Mahmoud and Ehab and the MEX
- POJ3273 Monthly Expense 二分法
- 人工智能入门简介及行业分析
- SAS数据集如何将为负数的部分,变为正数
- HDU 5127 Dogs' Candies【CDQ分治+动态凸包】
- 分析Hibernate:could not initialize proxy
- PHP的异步、并行、高性能网络通信引擎swoole的安装及websocket服务的使用
- [转]配置sonar、jenkins进行持续审查
- 综合 —— CORS 方式跨域访问