can you explain your logic.
1 Like
Check this case (if there is no fruit of type 1) :
1
6 4
4 2 3 3 2 2
7 3 9 1 1 1
First: There are multiple cases and you need to answer each case individually.
general format for answering multiple cases is:
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
// inputs for this case
// ...
// solve for this case
// ...
// output ans for this case
// ...
}
There may be other errors…
The fruits are 1 indexed (line: 29)