알고리즘

[알고리즘] 백준 20053 - 최소, 최대 2 (C++)

blueberrysoda 2024. 12. 29. 23:52

[문제 링크] : https://www.acmicpc.net/problem/20053

#include <iostream>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T, N, inp, Maxi, Mini;
    cin >> T;

    while(T--){
        cin >> N;
        Maxi = -1111111;
        Mini = 1111111;
        for(int i=0; i<N; i++){
            cin >> inp;
            Maxi = max(Maxi, inp);
            Mini = min(Mini, inp);
        }
        cout << Mini << " " << Maxi << "\n";
    }
    return 0;
}