제출 #1014511

#제출 시각아이디문제언어결과실행 시간메모리
1014511Khanhcsp2Autići (COCI22_autici)C++14
50 / 50
13 ms2220 KiB
#include<bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
#define int ll
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=1e5+11;
int n, a[N], pa[N];
pii b[N];
struct gg
{
    int u, v, w;
};
vector<gg> e;
int lead(int u)
{
    if(pa[u]==u) return u;
    return pa[u]=lead(pa[u]);
}
bool cmp(gg x, gg y)
{
    return x.w < y.w;
}
void sol()
{
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1, a+n+1);
    int ans=a[1]*(n-1);
    for(int i=2;i<=n;i++) ans+=a[i];
    cout << ans;

}
signed main()
{
//    freopen("divisor.INP", "r", stdin);
//    freopen("divisor.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--)
    {
        sol();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...