B. Hey, Better Bettor
2013 World Finals St. Petersburg HOSTED BY ITMO Problem B Hey, Better Bettor Time Limit: 4 seconds “In the casino, the cardinal rule is to keep them playing and to keep them coming back. The longer they play, the more they lose, and in the end, we get it...
Problem Statement
Formatted from the contest statement text, with sample tests broken out into copyable blocks.
“In the casino, the cardinal rule is to keep them playing and to keep them coming back. The
longer they play, the more they lose, and in the end, we get it all.”
(from the 1995 film Casino)
Recent recessions have not been kind to entertainment venues, including the gambling industry. Com- petition is fierce among casinos to attract players with lots of money, and some have begun to offer especially sweet deals. One casino is offering the following: you can gamble as much as you want at the casino. After you are finished, if you are down by any amount from when you started, the casino will refund x% of your losses to you. Obviously, if you are ahead, you can keep all of your winnings. There is no time limit or money limit on this offer, but you can redeem it only once. For simplicity, assume all bets cost 1 dollar and pay out 2 dollars. Now suppose x is 20. If you make 10 bets in total before quitting and only 3 of them pay out, your total loss is 3.2 dollars. If 6 of them pay out, you have gained 2 dollars. Given x and the percentage probability p of winning any individual bet, write a program to determine the maximum expected profit you can make from betting at this casino, using any gambling strategy.
Input
The input consists of a single test case. A test case consists of the refund percentage x (0 ≤ x < 100) followed by the winning probability percentage p (0 ≤ p < 50). Both x and p have at most two digits after the decimal point.
Output
Display the maximum expected profit with an absolute error of at most 10−3 .
Sample Tests
0 49.9 0.0 50 49.85 7.10178453 Editorial
The solution write-up is rendered from the LaTeX source, with equations kept live through MathJax.
Key Observations
Write the structural observations that make the problem tractable.
State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
If the constraints matter, explain exactly which part of the solution they enable.
Algorithm
Describe the data structures and the state maintained by the algorithm.
Explain the processing order and why it is sufficient.
Mention corner cases explicitly if they affect the implementation.
Correctness Proof
We prove that the algorithm returns the correct answer.
Lemma 1.
State the first key claim.
Proof.
Provide a concise proof.
Lemma 2.
State the next claim if needed.
Proof.
Provide a concise proof.
Theorem.
The algorithm outputs the correct answer for every valid input.
Proof.
Combine the lemmas and finish the argument.
Complexity Analysis
State the running time and memory usage in terms of the input size.
Implementation Notes
Mention any non-obvious implementation detail that is easy to get wrong.
Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
Code
C++ solution used for this page.
#include <bits/stdc++.h>
using namespace std;
namespace {
void solve() {
// Fill in the full solution logic for the problem here.
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Source Files and Assets
Raw files are still available here when you want the original TeX, C++, or statement assets.
Show raw files
competitive_programming/icpc/2013/B-hey-better-bettor/solution.texC++ implementationcompetitive_programming/icpc/2013/B-hey-better-bettor/solution.cppStatement textcompetitive_programming/icpc/2013/B-hey-better-bettor/statement.txtStatement PDFcompetitive_programming/icpc/2013/B-hey-better-bettor/statement.pdfMetadatacompetitive_programming/icpc/2013/B-hey-better-bettor/meta.jsonYear packetcompetitive_programming/icpc/2013/contest_problems.pdf