Submission #864415

#TimeUsernameProblemLanguageResultExecution timeMemory
864415TAhmed33Autići (COCI22_autici)C++98
10 / 50
30 ms1628 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 25; int arr[MAXN]; int main () { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i]; if (n == 1) { cout << "0\n"; return 0; } long long sum = 0; sort(arr + 1, arr + n + 1); for (int i = 1; i < n - 1; i++) sum += 2 * arr[i]; sum += arr[n - 1] + arr[n]; cout << sum << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...