codeforces Ilya and Matrix
http://codeforces.com/contest/313/problem/C
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 long long a[3000000]; 6 7 int main() 8 { 9 int n; 10 scanf("%d",&n); 11 for(int i=0; i<n; i++) 12 { 13 scanf("%lld",&a[i]); 14 } 15 sort(a,a+n); 16 long long ans=0,ans1=0; 17 int k=1,j=0; 18 for(int i=n-1; i>=0; i--) 19 { 20 ans1+=a[i]; 21 j++; 22 if(j==k) 23 { 24 ans+=ans1; 25 k=k*4; 26 } 27 } 28 printf("%lld\n",ans); 29 return 0; 30 }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步