#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
int N, A[100010], ans;
signed main() {
fast;
cin >> N;
for (int i = 1; i <= N; ++i) cin >> A[i];
sort(A + 1, A + 1 + N);
if (N == 1) return cout << 0, 0;
for (int i = 2; i <= N; ++i) ans += A[1] + A[i];
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
6 ms |
1220 KB |
Output is correct |
3 |
Correct |
13 ms |
2004 KB |
Output is correct |
4 |
Correct |
13 ms |
1904 KB |
Output is correct |
5 |
Correct |
14 ms |
1996 KB |
Output is correct |
6 |
Correct |
10 ms |
1784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
248 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
6 ms |
1220 KB |
Output is correct |
3 |
Correct |
13 ms |
2004 KB |
Output is correct |
4 |
Correct |
13 ms |
1904 KB |
Output is correct |
5 |
Correct |
14 ms |
1996 KB |
Output is correct |
6 |
Correct |
10 ms |
1784 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
248 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
312 KB |
Output is correct |
20 |
Correct |
0 ms |
324 KB |
Output is correct |
21 |
Correct |
6 ms |
1092 KB |
Output is correct |
22 |
Correct |
14 ms |
1980 KB |
Output is correct |
23 |
Correct |
11 ms |
1992 KB |
Output is correct |
24 |
Correct |
16 ms |
1912 KB |
Output is correct |
25 |
Correct |
20 ms |
2000 KB |
Output is correct |
26 |
Correct |
16 ms |
1868 KB |
Output is correct |
27 |
Correct |
18 ms |
2020 KB |
Output is correct |
28 |
Correct |
18 ms |
1748 KB |
Output is correct |
29 |
Correct |
17 ms |
1988 KB |
Output is correct |
30 |
Correct |
13 ms |
1996 KB |
Output is correct |