Help required in chef and proxy

my solution to the problem is even after passing almost all the manually created test cases. i got wa. anyone please help me with whats wrong in my code?

I might be wrong but it think your logic is wrong, also you should add brackets to keep precedence and associativity intact…lots of bracket issues in your code

1 Like

your solution is too complex ,but still this solution can work with a few changes

Line 28 : your always adding 1 to the required no of proxies. That is a wrong idea. You have to add 1 only when the total attendance is not divisible by 4. That is let’s assume that you have total no of days equal to 8. then required_attendance = 8 * 0.75 = 6 and not 8 * 0.75 + 1 = 7. This is the logic used there.

Even the variable prox is bit confusing in the for loop. If you already know how many proxy you need then the better option is decrementing the req variable which is the nod of required proxy in your program. If it doesn’t shoots to zero then the condition for the requirement is just fired up else print -1.

this is link to my solution its very very basic and simple. take a look and then follow up

1 Like

i am facing some issues in code of chef and proxy.
can you please help me with it?
my code is below:

#include <bits/stdc++.h>
using namespace std;

int main()
    int t;
    while(t - - )
        double n;
        string s;
        double p=0,need=0,a=0;
        for(int i=0;i<n;i++)

        int g=need;
        for(int i=2;i<n-2 && need!=0;i++)
                if((s[i-1]=='P' || s[i-2]=='P') && (s[i+1]=='P' || s[i+2]=='P'))

   else cout<<g<<endl;



Please Format your code.


Try :


The correct answer I believe is -1

PAAAPPP here A at index 2(index begins with 0) can be converted to P and also index 3.
its giving answer 2

Index 3 can’t. You might want to reread the question.

fine i got that!
i was converting A into P which we cannot.
Thanks for helping! :slight_smile: