Computer Science, asked by manjupol, 1 year ago

There are N bottles.ith bottle has A[j] radius once a bottle is enclosed inside another bottle.it ceases to be visible.minimize the number of visible bottles.you can put other bottle into jth bottle if following condition is fulfilled:

1.ith bottle itself is not enclosed in another bottle.

2.jth bottle does not enclose any other bottle.

3.Radius of bottle i is smaller than bottle j(i.e.A[i]

Answers

Answered by qwtiger
0

Answer:

#include <stdio.h>  

int main(){

int n;

scanf("%d, &n);  

int a[n], b[n], i, count=0;

for(i=0;i<n;i++)

{  scanf("%d, &a[i]);

b[i]=1;

}

sort(a, a+n);

for(i=0;i<n;i++)

{

for(int j = i+1;j<n;j++)

{

if(a[i]<a[j] && b[j] == 1)

{  count = count+1;

b[j] = 0;

break;

}

}

}

int result = n-count;

printf("\n %d", result);

}

Similar questions