알고리즘

[알고리즘] 백준 14487 - 욱제는 효도쟁이야!! (C++)

blueberrysoda 2024. 12. 27. 23:49

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, Cnt = 0, inp;
    vector<int> V;
    cin >> N;
    for(int i=0; i<N; i++){
        cin>> inp;
        V.push_back(inp);
    }
    sort(V.begin(), V.end());  
    for(int i=0; i<V.size()-1; i++){
        Cnt += V[i];
    }
    cout << Cnt << "\n";
    return 0;
}