Submission #1018565

#TimeUsernameProblemLanguageResultExecution timeMemory
1018565vjudge1Autići (COCI22_autici)C++17
10 / 50
10 ms2400 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()); y.push_back(x[n-1]); for(int i=0;i<n-1;i++){ y.push_back(x[i]); } for(int i=0;i<n-1;i++){ res+=(y[i]+y[i+1]); } 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...