Shoes Game

Xem PDF

Điểm: 400 Thời gian: 1.0s Bộ nhớ: 256M Input: bàn phím Output: màn hình

\(N + 1\) (\(N\) is odd number) shoes from \((N + 1)/2\) pair of shoes the same type with different sizes are lined up in a
random order. The game master secretly take one of the shoes out and hide it. The player need to guess whether the
hidden shoe is for left foot or right foot and what is its size.
Write a program to solve this game with cheating computer power.

Input

  • The first line of input contains the one integer \(N (1 \le N \le 10^5)\), the number of shoes.

  • The following line contains \(N\) integers \(S_1, S_2, ..., S_N (1 \le |S_i| \le 10^9)\). Shoe \(i\) is for left foot if \(S_i < 0\), otherwise it is for right foot. The size of the shoe is \(|S_i|\).

Output

  • Output one integer \(R\) where \(|R|\) is equal to the hidden shoe’s size and it is negative if it is a shoe for left foot, positive
    otherwise.

Example

Test 1

Input
3
1 5 -1
Output
-5

Bình luận


  • 0
    Mochiracvc1    11:07 p.m. 23 Tháng 1, 2024

    Mấy ah zai chỉ em với, em làm bài này theo code như này và nộp bên pypy đc có 4/10 thôi ạ =((
    a=int(input())
    b=list(map(int,input().split()))
    d=0
    e=0
    for i in b:
    if -i not in b:
    print(-i)
    Có cách nào nhanh hơn không ạ mấy anh zai chỉ em với =((. Em bị khờ, mấy ah zai thông cảm cho ạ.


    • 1
      minhtuanitk20    12:04 a.m. 24 Tháng 12, 2021

      bài này có nhiều cách các bạn có thể kết hợp sài set + find cũng được còn ko thì chỉ cần tính tổng r lấy giá trị âm của tổng đó là xong bài toán >>::


      • 0
        nguyendanghau2006    6:50 p.m. 19 Tháng 12, 2021

        bài này cỡ 100 là cùng, nhưng mà do bịp quá, nên lên 200 😃