#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define endl ('\n')
using namespace std;
void solve() {
int n;
cin>>n;
vector<int>x(n);
vector<int>y;
int res=0;
for(int i=0;i<n;i++){
cin>>x[i];
}
if(n==1){
cout<<0<<endl;
return;
}
sort(x.begin(),x.end());
for(int i=0;i<n-2;i++){
res+=2*x[i];
}
for(int i=n-2;i<n;i++){
res+=x[i];
}
cout<<res<<endl;
}
int32_t main(){
fast
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
1372 KB |
Output is correct |
3 |
Correct |
8 ms |
1948 KB |
Output is correct |
4 |
Correct |
9 ms |
1884 KB |
Output is correct |
5 |
Correct |
8 ms |
1884 KB |
Output is correct |
6 |
Correct |
7 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
1372 KB |
Output is correct |
3 |
Correct |
8 ms |
1948 KB |
Output is correct |
4 |
Correct |
9 ms |
1884 KB |
Output is correct |
5 |
Correct |
8 ms |
1884 KB |
Output is correct |
6 |
Correct |
7 ms |
1884 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |