TaroFriends
SRM 613 · 2013-12-22 · by Witaliy
Problem Statement
Cat Taro likes to play with his cat friends. Each of his friends currently sits on some coordinate on a straight line that goes from the left to the right. When Taro gives a signal, each of his friends must move exactly X units to the left or to the right.
You are given an
Constraints
- coordinates will contain between 1 and 50 elements, inclusive.
- Each element of coordinates will be between -100,000,000 and 100,000,000, inclusive.
- X will be between 0 and 100,000,000, inclusive.
{-3, 0, 1}
3
Returns: 3
The difference 3 is obtained if the cats move from {-3,0,1} to {0,-3,-2}.
{4, 7, -7}
5
Returns: 4
The difference 4 is obtained if the cats move from {4,7,-7} to {-1,2,-2}.
{-100000000, 100000000}
100000000
Returns: 0
{3, 7, 4, 6, -10, 7, 10, 9, -5}
7
Returns: 7
{-4, 0, 4, 0}
4
Returns: 4
Submissions are judged against all 244 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TaroFriends with a public method int getNumber(vector<int> coordinates, int X) · 244 test cases · 2 s / 256 MB per case