462C - Appleman and Toastman - CodeForces Solution


implementation sortings *1200

Please click on ads to support us..

C++ Code:

 
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int  ll;

#define pi(x) cout<<x;
#define ps(x) cout<<x<<" ";
#define pnl(x) cout<<x<<"\n";
#define for0(n) for(i=0;i<n;i++)
#define for1(n) for(i=1;i<=n;i++)
#define m(x) memset(x,0,sizeof x);
#define nl cout<<"\n";
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define Inf 1e16


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);                                                                                             
ll test,h,i,j,xy,flag=0,n,p,u,count,d,o1=0,o2=0,s,e,l,r,x,y,m,z,max1,x1,y1,k,x2,y2,z1,z2,sum,min1;


cin>>n;
vector<ll>a(n);
sum=0;
for(i=0;i<n;i++){
 cin>>a[i];
}
sort(a.begin(),a.end());
for(i=0;i+1<n;i++){
    sum+=a[i]*(i+2);
}
sum+=a[n-1]*n;
cout<<sum<<"\n";

return 0;
}


Comments

Submit
0 Comments
More Questions

1538A - Stone Game
1454C - Sequence Transformation
165B - Burning Midnight Oil
17A - Noldbach problem
1350A - Orac and Factors
1373A - Donut Shops
26A - Almost Prime
1656E - Equal Tree Sums
1656B - Subtract Operation
1656A - Good Pairs
1367A - Short Substrings
87A - Trains
664A - Complicated GCD
1635D - Infinite Set
1462A - Favorite Sequence
1445B - Elimination
1656C - Make Equal With Mod
567A - Lineland Mail
1553A - Digits Sum
1359B - New Theatre Square
766A - Mahmoud and Longest Uncommon Subsequence
701B - Cells Not Under Attack
702A - Maximum Increase
1656D - K-good
1426A - Floor Number
876A - Trip For Meal
1326B - Maximums
1635C - Differential Sorting
961A - Tetris
1635B - Avoid Local Maximums