## MWC '15 #4 P2: Data Formatting

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Salarios77 deals with large amounts of numbers on a daily basis. To ensure consistency in his storage of special numbers, he likes following a particular format when possible:

• for all even (ascending order).
• for all odd (descending order).

Given some records of numbers, determine if it is possible to follow the pattern, and if possible output the pattern.

#### Input Specification

First line contains , the amount of numbers provided. The second line consists of spaced integers, which represent th value.

#### Output Specification

If it is impossible, output: IMPOSSIBLE. If it is possible, output the integers in order separated by a space.

#### Sample Input 1

4
1 1 1 1

#### Sample Output 1

1 1 1 1

#### Sample Input 2

4
1 3 3 4

#### Sample Output 2

1 4 3 3

• commented on July 1, 2020, 11:25 p.m. edit 2

The problem is a bit confusing but essentially we only look at the output integers'formatting but not the input ones

• commented on July 18, 2019, 1:52 p.m.

You might want to consider stating the restrictions for n.

• commented on Aug. 25, 2017, 7:41 p.m. edited

Shouldn't it say

• for all even (ascending order).
• for all odd (descending order).
• commented on April 16, 2016, 12:44 p.m.

If the input is

4
2 4 6 8

Is the "2" the first term or the zero-th term?

• commented on April 16, 2016, 1:20 p.m.

Zero-th term. The output would be 2 8 4 6. The even terms would be 2 and 4, while the odd terms would be 8 and 6.

• commented on April 16, 2016, 12:09 a.m.

Shouldn't sample output 2 be "1 3 3 4" as this minimizes the difference?

• commented on April 16, 2016, 12:44 a.m.

In fact you don't need to worry about the differences, just take note at the statement:

for all even .

• commented on April 16, 2016, 12:41 a.m.

Sorry, the problem statement was not clear. The minimized difference must be for every other term, so like: _3_4, ignore the 1 and 3. Same goes for 1_3_. In other words the minimized difference between consecutive odd/even indexed terms only.