682B. Alyona and Mex

Problem Link

<Solution>

#include <bits/stdc++.h>
using namespace std;

#define INF 10000000

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<int> si;
typedef map<string, int> msi;

#define all(x) sort(x.begin(), x.end())
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define spresent(c,x) ((c).find(x) != (c).end()) // for set,map
#define present(c,x) (find(all(c),x) != (c).end()) // for vector
#define uu first
#define vv second
#define fr(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nfr(i,a,b) for(int i= int(a);i>=int(b);–i)

int main()
{
int n,x,i,co=1;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];

}
sort(a,a+n);
//for(i=0;i<n;i++)
// cout<<a[i]<<‘ ‘;
// cout<<endl;
for(i=0;i<n;i++)
{
if(a[i]>=co)
co++;

}
cout<<co<<endl;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Codeforces, Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s