Submission #1018593

#TimeUsernameProblemLanguageResultExecution timeMemory
1018593vjudge1Autići (COCI22_autici)C++17
10 / 50
9 ms1948 KiB
#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(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...