CopyingHomework
TCO19 SRM 748 · 2019-01-09 · by misof
TCO19 SRM 748 · 2019-01-09 · by misof · Simple Math, Simple Search, Iteration
Problem Statement
Problem Statement
- "Dude, can I copy your homework?"
- "Sure, but change it a little, so it doesn't look like we cheated."
You are given the
- yourHomework must have exactly 5 elements.
- For each i, yourHomework[i] must differ from friendsHomework[i] (so it doesn't look like you cheated).
- For each i, the difference between yourHomework[i] and friendsHomework[i] must be at most 10 (so that the values are similar).
- The sum of yourHomework must be the same as the sum of friendsHomework (so that you both get the same final result).
Notes
- Any valid solution will be accepted.
Constraints
- friendsHomework will contain exactly 5 elements.
- Each element of friendsHomework will be between 0 and 1000, inclusive.
Examples
0)
{10, 20, 30, 40, 50}
Returns: {9, 19, 29, 39, 54 }
1)
{0, 0, 0, 0, 0}
Returns: {-1, -1, -1, -1, 4 }
Note that the values in yourHomework may lie outside the range [0,1000]. As long as they satisfy the constraints from the problem statement, you have a valid answer.
2)
{400,399,400,399,400}
Returns: {399, 398, 399, 398, 404 }
3)
{1000,1000,1000,1000,1000}
Returns: {999, 999, 999, 999, 1004 }
4)
{360,64,440,566,464}
Returns: {359, 63, 439, 565, 468 }
Submissions are judged against all 55 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class CopyingHomework with a public method vector<int> copy(vector<int> friendsHomework) · 55 test cases · 2 s / 256 MB per case