https://www.acmicpc.net/problem/10818

 

10818번: 최소, 최대

첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다.

www.acmicpc.net

using System;
using System.Text;

namespace BackJoonStudy
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int[] arr = new int[N];

            string[] s = Console.ReadLine().Split();

            for(int i=0; i<N; i++)
            {
                arr[i] = int.Parse(s[i]);
            }

            Array.Sort(arr);
            Console.WriteLine(arr[0] +" "+arr[N-1]);

        }
    }
}

+ Recent posts