cswork / OAOpen practice workspace

BlackrockOA #1

Road Trip (Analyst Program :P

EasyJudge-ready

Topics (AI-labelled)StringsIn-place Arrays

Given the distance from the start of each city's gas station along a straight route, output the distance from the start to the first station and then between each pair of subsequent adjacent stations.

Input

One line containing 1..5000 items of the form city name, distance, separated by semicolons, possibly with a trailing semicolon. City names are non-empty and contain no commas or semicolons; distances are integers in 0..1000000000.

Output

After sorting by distance from the start in ascending order, output the distance from the start to the first station and the distances between adjacent stations, separated by an ASCII comma and a space; stations at the same position are 0 apart.

Example 1

Input:

Rkbs, 5453; Wdqiz, 1245; Rwds, 3890; Ujma, 5589; Tbzmo, 1303;

Output:

1245, 58, 2587, 1563, 136

Example 2

Input:

Near, 0;

Output:

0

Example 3

Input:

Far, 1000000000; Other, 1000000000; Middle, 500000000;

Output:

500000000, 500000000, 0

Editorial

Loading solution…