CF1866A.Ambitious Kid

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Chaneka, Pak Chanek's child, is an ambitious kid, so Pak Chanek gives her the following problem to test her ambition.

Given an array of integers [A1,A2,A3,…,AN][A_1, A_2, A_3, \ldots, A_N]. In one operation, Chaneka can choose one element, then increase or decrease the element's value by 11. Chaneka can do that operation multiple times, even for different elements.

What is the minimum number of operations that must be done to make it such that A1×A2×A3×…×AN=0A_1 \times A_2 \times A_3 \times \ldots \times A_N = 0?

Chaneka 是 Pak Chanek 的孩子,是一位雄心勃勃的小孩,因此 Pak Chanek 给了她如下问题来测试她的雄心。

给定一个整数数组 [A1,A2,A3,…,AN][A_1, A_2, A_3, \ldots, A_N]。在一次操作中,Chaneka 可以选择其中一个元素,并将其值增加或减少 11。Chaneka 可以执行该操作多次,甚至对不同的元素执行。

为使 A1×A2×A3×…×AN=0A_1 \times A_2 \times A_3 \times \ldots \times A_N = 0 成立,所需的最少操作次数是多少?

输入格式

The first line contains a single integer NN (1≤N≤1051 \leq N \leq 10^5).

The second line contains NN integers A1,A2,A3,…,ANA_1, A_2, A_3, \ldots, A_N (−105≤Ai≤105-10^5 \leq A_i \leq 10^5).

第一行包含一个整数 NN(1≤N≤1051 \leq N \leq 10^5)。

第二行包含 NN 个整数 A1,A2,A3,…,ANA_1, A_2, A_3, \ldots, A_N(−105≤Ai≤105-10^5 \leq A_i \leq 10^5)。

输出格式

An integer representing the minimum number of operations that must be done to make it such that A1×A2×A3×…×AN=0A_1 \times A_2 \times A_3 \times \ldots \times A_N = 0.

一个整数,表示使 A1×A2×A3×…×AN=0A_1 \times A_2 \times A_3 \times \ldots \times A_N = 0 成立所需的最少操作次数。

输入输出样例

  • 输入#1

    3
    2 -6 5

    输出#1

    2
  • 输入#2

    1
    -3

    输出#2

    3
  • 输入#3

    5
    0 -1 0 1 0

    输出#3

    0

说明/提示

In the first example, initially, A1×A2×A3=2×(−6)×5=−60A_1\times A_2\times A_3=2\times(-6)\times5=-60. Chaneka can do the following sequence of operations:

  1. Decrease the value of A1A_1 by 11. Then, A1×A2×A3=1×(−6)×5=−30A_1\times A_2\times A_3=1\times(-6)\times5=-30
  2. Decrease the value of A1A_1 by 11. Then, A1×A2×A3=0×(−6)×5=0A_1\times A_2\times A_3=0\times(-6)\times5=0

In the third example, Chaneka does not have to do any operations, because from the start, it already holds that A1×A2×A3×A4×A5=0×(−1)×0×1×0=0A_1\times A_2\times A_3\times A_4\times A_5=0\times(-1)\times0\times1\times0=0

在第一个例子中,初始时,A1×A2×A3=2×(−6)×5=−60A_1\times A_2\times A_3=2\times(-6)\times5=-60。Chaneka 可以执行以下操作序列:

  1. 将 A1A_1 的值减小 11。此时,A1×A2×A3=1×(−6)×5=−30A_1\times A_2\times A_3=1\times(-6)\times5=-30
  2. 将 A1A_1 的值减小 11。此时,A1×A2×A3=0×(−6)×5=0A_1\times A_2\times A_3=0\times(-6)\times5=0

在第三个例子中,Chaneka 无需执行任何操作,因为初始时已满足 A1×A2×A3×A4×A5=0×(−1)×0×1×0=0A_1\times A_2\times A_3\times A_4\times A_5=0\times(-1)\times0\times1\times0=0

输入解题思路,AI测评打分。不知道怎么写?

首页