Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Bai1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n;
- int[] a;
- bool[] res;
- n = int.Parse(Console.ReadLine());
- a = new int[n];
- string[] temp = Console.ReadLine().Split();
- for (int i = 0; i < n; i++)
- {
- a[i] = int.Parse(temp[i]);
- }
- int maxTemp = findMax(a);
- res = new bool[maxTemp + 1];
- for (int i = 0; i < n; i++)
- {
- res[a[i]] = true;
- }
- for (int i = 1; i < res.Length; i++)
- {
- if (!res[i]) {
- Console.WriteLine(i);
- break;
- }
- }
- }
- static int findMax(int[] a)
- {
- int max = a[0];
- for (int i = 1; i < a.Length; i++)
- {
- if (a[i] > max) max = a[i];
- }
- return max;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement