#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N];
void solve(){
int n;
cin>>n;
for(int i=1;i<=n;i++) cin>>t[i];
sort(t+1,t+1+n);
ll sum=0;
for(int i=2;i<=n;i++) sum+=(ll)t[i];
cout<<(ll)(n-1)*(ll)(t[1])+sum<<"\n";
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
int tt=1;
while(tt--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
856 KB |
Output is correct |
3 |
Correct |
13 ms |
1620 KB |
Output is correct |
4 |
Correct |
11 ms |
1496 KB |
Output is correct |
5 |
Correct |
11 ms |
1620 KB |
Output is correct |
6 |
Correct |
10 ms |
1436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
496 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
856 KB |
Output is correct |
3 |
Correct |
13 ms |
1620 KB |
Output is correct |
4 |
Correct |
11 ms |
1496 KB |
Output is correct |
5 |
Correct |
11 ms |
1620 KB |
Output is correct |
6 |
Correct |
10 ms |
1436 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
496 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
856 KB |
Output is correct |
22 |
Correct |
14 ms |
1708 KB |
Output is correct |
23 |
Correct |
11 ms |
1680 KB |
Output is correct |
24 |
Correct |
16 ms |
1492 KB |
Output is correct |
25 |
Correct |
17 ms |
1652 KB |
Output is correct |
26 |
Correct |
17 ms |
1492 KB |
Output is correct |
27 |
Correct |
18 ms |
1592 KB |
Output is correct |
28 |
Correct |
17 ms |
1464 KB |
Output is correct |
29 |
Correct |
18 ms |
1596 KB |
Output is correct |
30 |
Correct |
16 ms |
1620 KB |
Output is correct |