Problem:
Please find the problem here.
Solution:
This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.
Explanation:
Please find the problem here.
Solution:
This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.
Explanation:
1.MEX has two condition
2.MEX equal to entered input ... MEX will increase by 1 as element is erased.
3.MEX less than input...MEX will decline as element is inserted before MEX
4.Goodluck!
Code:
Code:
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
int n;
int k;
int x;
cin>>n>>k;
int ans=k;
FOR(i,n){
cin>>x;
if(x<k){
ans--;
}
else if(x==k){
ans++;
}
}
cout<<ans;
}
sir tell me more about this problem.....am new student plz sir .......i don't understand this problem.
ReplyDelete