Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- const int MAX_SIZE = 1000000;
- int main() {
- int N, temp, Ivancho = 1;
- int arr[MAX_SIZE];
- cin >> N;
- for (int i = 0; i < N; i++) {
- cin >> arr[i];
- }
- sort(arr, arr + N);
- bool hasOne = false;
- for (int i = 1; i <= N; i++) {
- if (arr[i - 1] == 1)
- {
- hasOne = true;
- }
- if (arr[i - 1] > 0 && arr[i] - arr[i - 1] > 1) {
- Ivancho = arr[i - 1] + 1;
- break;
- }
- else if (arr[i - 1] > 0 && i == N)
- {
- Ivancho = arr[i - 1] + 1;
- break;
- }
- }
- if (hasOne == false)
- {
- Ivancho = 1;
- }
- cout << Ivancho;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment