Advertisement
erfanul007

CF 526 Div 2 - A

Dec 10th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. int n,a[110],ut[110],nt[110],i,k,j,l,m,total,min,x,combo;
  6. scanf("%d",&n);
  7. for(i=1;i<=n;i++){
  8. scanf("%d",&a[i]);
  9. }
  10. min=99999999;
  11. for(x=1;x<=n;x++){
  12. total=0;
  13. for(j=1;j<=n;j++){
  14. l=abs(x-j);
  15. m=x-1;
  16. k=j-1;
  17. nt[j]=(k+l+m)*a[j];
  18. ut[j]=(k+m+l)*a[j];
  19. combo=nt[j]+ut[j];
  20. total=total+combo;
  21. }
  22. if(total<min)
  23. min=total;
  24. }
  25. printf("%d\n",min);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement