Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 2014-01-28 09:35:04.

SMPSEQ9 - Fun with Sequences (Act 7)

You are given a sequence of n integers S = s1, s2 ... sn and a sequence of m integers Q = q1, q2 ... qm. If (q1 + q2 + ... + qm)/m < (s1 + s2 + ... + sn)/n please print the sequence S and otherwise please print the sequence Q.

Input data specification

In the first line you are given one integer 2 <= n <= 100, and in the following line n integers:
-100 <= si <= 100.

In the third line you are given one integer 2 <= m <= 100, and in the following line m integers:
-100 <= qi <= 100.

Output data specification

The sequence of requested integers separated by spaces in the same order as in the input.

Example 1

Input:
5
-2 -1 0 1 4
6
-3 -2 -1 1 2 3

Output:
-2 -1 0 1 4

Example 2

Input:
5
-2 -1 1 2 3
6
-2 -1 0 1 2 3

Output:
-2 -1 1 2 3

Added by:kuszi
Date:2014-01-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Public source code since: 2014-01-28 09:35:04

hide comments
2021-06-21 16:16:54 kuszi
Explanation to 2nd test case:
( (-2) + (-1) + 0 + 1 + 2 + 3 ) / 6 = 3/6 = 0.5 < ( (-2) + (-1) + 1 + 2 + 3 ) / 5 = 3/5 = 0.6
so the answer is the sequence s.
2021-05-16 00:03:41
2nd test case output is wrong
2015-12-10 13:06:41
code ??
2014-08-28 06:25:00 sarkarshuvojit
i'm getting an NZEC. what might be the flaw o.O ? Help anybody ?? _/\_
2014-07-28 12:27:44 kuszi
@Rounaq Jhunjhunu Wala - you are given integers, the answer will not come out to be a fraction.

Please treat the comparison given in the statement as a comparison of real values (do not use an integer division).
2014-07-21 05:58:27 Rounaq Jhunjhunu Wala
If the answer comes out to be a fraction, do we need to compare the decimal values or we print the second array, as we do for cases for equality of sum?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.