You are not logged in. Please login at www.codechef.com to post your questions!

×

EGYPIZZA SPOJ

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

vsukeeshbabu's gravatar image

2★vsukeeshbabu
78727
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;

}

link
This answer is marked "community wiki".

answered 12 Apr '17, 15:18

abis's gravatar image

1★abis
11
accept rate: 0%

edited 12 Apr '17, 15:23

-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.

link

answered 14 Jan '15, 15:49

michelangelo's gravatar image

4★michelangelo
1.1k21522
accept rate: 39%

@michelangelo answer is 4 itself .. What about Pizza for Abotrika?

(15 Jan '15, 21:28) vsukeeshbabu2★

correct ans is 4

(23 Feb '17, 13:29) neilit19923★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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