#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();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
1372 KB |
Output is correct |
3 |
Correct |
11 ms |
2028 KB |
Output is correct |
4 |
Correct |
7 ms |
1884 KB |
Output is correct |
5 |
Correct |
8 ms |
2208 KB |
Output is correct |
6 |
Correct |
8 ms |
1960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
476 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
1372 KB |
Output is correct |
3 |
Correct |
11 ms |
2028 KB |
Output is correct |
4 |
Correct |
7 ms |
1884 KB |
Output is correct |
5 |
Correct |
8 ms |
2208 KB |
Output is correct |
6 |
Correct |
8 ms |
1960 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
476 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
4 ms |
1372 KB |
Output is correct |
22 |
Correct |
8 ms |
2220 KB |
Output is correct |
23 |
Correct |
8 ms |
2120 KB |
Output is correct |
24 |
Correct |
13 ms |
1884 KB |
Output is correct |
25 |
Correct |
13 ms |
2140 KB |
Output is correct |
26 |
Correct |
11 ms |
2068 KB |
Output is correct |
27 |
Correct |
13 ms |
2140 KB |
Output is correct |
28 |
Correct |
11 ms |
2020 KB |
Output is correct |
29 |
Correct |
12 ms |
2088 KB |
Output is correct |
30 |
Correct |
10 ms |
2140 KB |
Output is correct |