×

# EGYPIZZA SPOJ

 0 Couldn't find out the reason for WA on SPOJ ? ? ! .. though it's a easy question .. but getting WA .. Don't know which case i m missing .. My Code : : http://ideone.com/m7N8OF Problem : : http://www.spoj.com/problems/EGYPIZZA/ .. Thanks in advance :) ! asked 14 Jan '15, 00:12 78●7●27 accept rate: 0%

CODE:

# include<bits stdc++.h="">

using namespace std; map<string,double> m; int main() {

m["1/4"]=0.25;
m["1/2"]=0.50;
m["3/4"]=0.75;
int n;
cin>>n;
int co25=0, co50=0, co75=0;
for(int i=0; i<n; ++i)
{
string s;
cin>>s;
if(m[s]==0.75)
++co75;
else if(m[s]==0.50)
++co50;
else
++co25;
}
int ans=co75+ceil((double)co50/2.0)+1;
int wasted=co75;
if(co50%2)
wasted+=2;
co25-=wasted;
if(co25>0)
{
ans+=ceil((double)co25/4.0);
}
cout<<ans;
return 0;


}

This answer is marked "community wiki".

1★abis
11
accept rate: 0%

 -1 Hi! There's a slight error in your logic. It doesn't minimize the total number of pizzas. In fact it is wrong for the test case you provided at ideone. 5 1/2 3/4 1/2 1/4 1/4 Your answer is 4 but the correct answer is 3 (1 pizza for 3/4, 1 pizza for (1/2 + 1/4 +1/4), 1 pizza for 1/2). For correct implementation see http://discuss.codechef.com/questions/54773/spoj-egypizza. answered 14 Jan '15, 15:49 1.1k●2●15●22 accept rate: 39% @michelangelo answer is 4 itself .. What about Pizza for Abotrika? (15 Jan '15, 21:28) correct ans is 4 (23 Feb '17, 13:29)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,718
×2,356
×1,136
×1,070
×428
×13

question asked: 14 Jan '15, 00:12

question was seen: 4,906 times

last updated: 12 Apr '17, 15:23