codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

45I.md (1820B)


      1 Source: https://codeforces.com/problemset/problem/45/I
      2 
      3 I. TCMCF+++
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Vasya has gotten interested in programming contests in TCMCF+++ rules. On the contest *n* problems were suggested and every problem had a cost — a certain integral number of points (perhaps, negative or even equal to zero). According to TCMCF+++ rules, only accepted problems can earn points and the overall number of points of a contestant was equal to the product of the costs of all the problems he/she had completed. If a person didn't solve anything, then he/she didn't even appear in final standings and wasn't considered as participant. Vasya understood that to get the maximal number of points it is not always useful to solve all the problems. Unfortunately, he understood it only after the contest was finished. Now he asks you to help him: find out what problems he had to solve to earn the maximal number of points.
     22 
     23 Input
     24 
     25 The first line contains an integer *n* (1 ≤ *n* ≤ 100) — the number of the suggested problems. The next line contains *n* space-separated integers *c**i* ( - 100 ≤ *c**i* ≤ 100) — the cost of the *i*-th task. The tasks' costs may coinсide.
     26 
     27 Output
     28 
     29 Print space-separated the costs of the problems that needed to be solved to get the maximal possible number of points. Do not forget, please, that it was necessary to solve at least one problem. If there are several solutions to that problem, print any of them.
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 5  
     37 1 2 -3 3 3
     38 ```
     39 
     40 Output
     41 
     42 ```
     43 3 1 2 3
     44 ```
     45 
     46 Input
     47 
     48 ```
     49 13  
     50 100 100 100 100 100 100 100 100 100 100 100 100 100
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 100 100 100 100 100 100 100 100 100 100 100 100 100
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 4  
     63 -2 -2 -2 -2
     64 ```
     65 
     66 Output
     67 
     68 ```
     69 -2 -2 -2 -2
     70 ```