Please help me with this (WA in CHPINTU)

https://www.codechef.com/viewsolution/32170637

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…

i am getting ans 0
Also i have modified it
https://www.codechef.com/viewsolution/32172117

still an error
https://www.codechef.com/viewsolution/32172117

The fruits are 1 indexed (line: 29)