Editing
2019 Dec Platinum Problem 1 Greedy Pie Eaters
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Official Problem Statement == [http://www.usaco.org/index.php?page=viewproblem2&cpid=972 Greedy Pie Eaters] ==Problem Statement:== Greedy Pie Eaters is a USACO problem that requires you to determine the maximum number of pies that can be eaten by a group of people. The pies are arranged in a circle, and each person can only eat the pies that are directly in front of them. ==Solution:== The solution to this problem involves using a greedy algorithm. We can iterate through the pies in the circle, and for each pie, we can check whether the person in front of it has already eaten a pie. If not, we can add one to the total number of pies eaten. This process is repeated until all pies have been checked. In C++, this can be implemented as follows: <pre> int maxPies(vector<bool> pies) { int count = 0; for (int i = 0; i < pies.size(); i++) { if (!pies[i]) { count++; pies[(i+1) % pies.size()] = true; } } return count; } </pre> [[Category:Yearly_2019_2020]] [[Category:Platinum]] [[Category:Dynamic Programming]] [[Category:Segment Tree]] [[Category:Range Query]]
Summary:
Please note that all contributions to Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information