1 / 9
Mar 2012

This is a sticky that I just wrote. The reason I wrote it is because this is not the first time someone has come across this issue:
spoj.pl/forum/viewtopic.php?f=41&t=108551

Having said that, this may not resolve your issue, if you still have an issue, please post your updated code.

Sir,Thanks for your advice. I have corrected my code.
Now Please see why I am getting wrong answer??

code removed........

Here is the updated version of my code. Please check it.Its still giving me WA.

code removed after ACC

Your logic is not correct. Think about how you would perform this in person.

1 year later

PLS help!! My code seems to be working but it says wrong answer!

include

include

using namespace std;
int main()
{
unsigned short t,q,h,m,s;
char a[4],b[3][4]= {"1/4","1/2","3/4"};
vector quar;
vector half;
vector thref;
cin>>t;
s=1;
while(t--)
{
cin>>a;
if(strcmp(a,b[0])==0)
quar.push_back(.25);
else if(strcmp(a,b[1])==0)
half.push_back(0.5);
else if(strcmp(a,b[2])==0)
thref.push_back(.75);
}
q = quar.size();
h = half.size();
m = thref.size();
s = s + q/4 + h/2 ;
h = h - h/2;
q = q - q/4;
q = q%4; h = h%2;
if(h!=0 && q!=0)
if(q/2!=0)
{
if(q/2>h)
while(h!=0)
{
q=q-2; h--; s++;
}
else
while(q/2!=0)
{
q=q-2; h--; s++;
}
}
while(q!=0)
{
q--; m--; s++;
}
while(h!=0)
{
h--; s++;
}
while(m!=0)
{
m--; s++;
}
cout< return 0;
}

Please use code tags when posting code.

Why are you trying to insert floating point numbers into integer datatypes?