Sir I am solving the question Pizza http://www.spoj.pl/problems/EGYPIZZA/
Code Removed..........
I am getting Wrong Answer. Please tell a test case where my code fails
created
last reply
- 8
replies
- 372
views
- 3
users
- 2
links
Sir I am solving the question Pizza http://www.spoj.pl/problems/EGYPIZZA/
Code Removed..........
I am getting Wrong Answer. Please tell a test case where my code fails
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.
PLS help!! My code seems to be working but it says wrong answer!
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;
}