Computer Science, asked by shetarpita9076, 6 months ago

Alex has been preparing a box for handicraft. The box consists of N pieces of stones with each stone having a certain weight assigned to it. Each stone in the box will carry a different weight. This means no two stones can have the same weight. Alex wants to do this by making minimal changes in the original weight of the stones, making each stone weigh at least as much as its original weight. Find the minimum total weight that he can set for the

box.

Note: Stone weights are not in float value.

Input

1. First input contains N, the total number of stones in

the box

2. Second input contains N sorted integers separated

by newline A1, A2... An, representing the original​

Answers

Answered by brajeshkumardwivedi4
1

Answer:

this is why to write this answer as our friends

Explanation:

hope all is well and that is why would they like it was great to hear about your order has not been in contact soon and I

Answered by ravilaccs
0

The Program is given by Python and C

Explanation:

a=int(input())

b=list(map(int,input().split()))

d=[]

if(len(b)>a):

 print("Wrong Input")

else:

 for i in b:

   if i not  in d:

     d.append(i)

  else:

     d.append(i+1)

 print(sum(d))

include <stdio.h>

int main()

{

   int N,arr[100],ind,count=0,sum=0;

   scanf("%d",&N);

   for(ind=0;ind<N;ind++)

       scanf("%d",&arr[ind]);

   for(ind=0;ind<N;ind++)

   {

       if(arr[ind]!=0)

           count++;

   }

   if(count==N)

   {

      for(ind=0;ind<N;ind++)

      {

          if(arr[ind]==arr[ind+1])

               arr[ind+1]++;

           sum = sum + arr[ind];

      }

      printf("%d",sum);

   }

   else

   {

       printf("wrong input");

   }

   return 0;

}

Similar questions