Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- int n,a[110],ut[110],nt[110],i,k,j,l,m,total,min,x,combo;
- scanf("%d",&n);
- for(i=1;i<=n;i++){
- scanf("%d",&a[i]);
- }
- min=99999999;
- for(x=1;x<=n;x++){
- total=0;
- for(j=1;j<=n;j++){
- l=abs(x-j);
- m=x-1;
- k=j-1;
- nt[j]=(k+l+m)*a[j];
- ut[j]=(k+m+l)*a[j];
- combo=nt[j]+ut[j];
- total=total+combo;
- }
- if(total<min)
- min=total;
- }
- printf("%d\n",min);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement