EllysNumberGuessing
SRM 606 · 2013-12-22 · by espr1t
Problem Statement
You are given a
Constraints
- guesses and answers will each contain between 1 and 50 elements, inclusive.
- guesses and answers will contain the same number of elements.
- Each element of guesses will be between 1 and 1,000,000,000, inclusive.
- Each element of answers will be between 1 and 999,999,999, inclusive.
{600, 594}
{6, 12}
Returns: 606
Apparently Kristina has thought of the number of this SRM.
{100, 50, 34, 40}
{58, 8, 8, 2}
Returns: 42
It is not guaranteed that Elly has used a perfect strategy so far.
{500000, 600000, 700000}
{120013, 220013, 79987}
Returns: -2
The answers here are inconsistent. After the second guess we can conclude that the answer is below 500000. But the third one indicates that it is above 500000. Thus, Kristina is a liar and you should return -2.
{500000000}
{133742666}
Returns: -1
There are multiple possibilities here, thus you should return -1.
{76938260, 523164588, 14196746, 296286419, 535893832,
41243148, 364561227, 270003278, 472017422, 367932361,
395758413, 301278456, 186276934, 316343129, 336557549,
52536121, 98343562, 356769915, 89249181, 335191879}
{466274085, 20047757, 529015599, 246925926, 7318513,
501969197, 178651118, 273209067, 71194923, 175279984,
147453932, 241933889, 356935411, 226869216, 206654796,
490676224, 444868783, 186442430, 453963164, 208020466}
Returns: 543212345
{42}
{42}
Returns: 84
Don't forget that the number Kris has thought of must be between 1 and 1,000,000,000.
{999900000}
{100001}
Returns: 999799999
Don't forget that the number Kris has thought of must be between 1 and 1,000,000,000.
Submissions are judged against all 161 archived test cases, of which 7 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class EllysNumberGuessing with a public method int getNumber(vector<int> guesses, vector<int> answers) · 161 test cases · 2 s / 256 MB per case