当前位置: 首页 > ai >正文

A. Ambitious Kid

time limit per test

1 second

memory limit per test

256 megabytes

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][A1,A2,A3,…,AN]. 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=0A1×A2×A3×…×AN=0?

Input

The first line contains a single integer NN (1≤N≤1051≤N≤105).

The second line contains NN integers A1,A2,A3,…,ANA1,A2,A3,…,AN (−105≤Ai≤105−105≤Ai≤105).

Output

An integer representing the minimum number of operations that must be done to make it such that A1×A2×A3×…×AN=0A1×A2×A3×…×AN=0.

Examples

Input

Copy

3
2 -6 5

Output

Copy

2

Input

Copy

1
-3

Output

Copy

3

Input

Copy

5
0 -1 0 1 0

Output

Copy

0

Note

In the first example, initially, A1×A2×A3=2×(−6)×5=−60A1×A2×A3=2×(−6)×5=−60. Chaneka can do the following sequence of operations:

  1. Decrease the value of A1A1 by 11. Then, A1×A2×A3=1×(−6)×5=−30A1×A2×A3=1×(−6)×5=−30
  2. Decrease the value of A1A1 by 11. Then, A1×A2×A3=0×(−6)×5=0A1×A2×A3=0×(−6)×5=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=0

解题说明:水题,找到绝对值最小的数,然后将该数变成0即可。

#include<stdio.h>
int main()
{int n, x, ans = 1e5;scanf("%d", &n);for (int i = 0; i < n; ++i){scanf("%d", &x);if (abs(x) <= ans){ans = abs(x);}}printf("%d", ans);return 0;
}

http://www.xdnf.cn/news/2078.html

相关文章:

  • MySQL 联合查询教程
  • 使用PyTorch实现简单图像识别(基于MNIST手写数字数据集)的完整代码示例,包含数据加载、模型定义、训练和预测全流程
  • 深度探索:DeepSeek赋能WPS图表绘制
  • Docker化HBase排错实录:从Master hflush启动失败到Snappy算法未支持解决
  • Oracle官宣 MySQL+APEX+AI三认证限时免费
  • 使用 AFL++ 对 IoT 二进制文件进行模糊测试 - 第二部分
  • 基于 Requests 与 Ollama 的本地大模型交互全栈实践指南
  • Trae 宝藏功能实测:从 Mcp 搭建天气系统,到 AI 重塑 Excel 数据处理
  • 精通线程池:业务场景中的实践、优化与监控
  • maven打包时配置多环境参数
  • 深入理解二叉树遍历:递归与栈的双重视角
  • php一些命名规范 和 css命名规范
  • 支付宝小程序组件与页面构造器使用指南:从页面到组件的正确迁移
  • 【Agent实战】从0到1开发一个Python 解释器 MCP SSE Server
  • RocketMQ 主题与队列的协同作用解析(既然队列存储在不同的集群中,那要主题有什么用呢?)---管理命令、配置安装(主题、消息、队列与 Broker 的关系解析)
  • 7年经验的Java程序员的技术知识概览(及分阶段学习计划、资源推荐、职业发展建议)
  • 基于Java(JSP)+MySQL实现深度学习的音乐推荐系统
  • Queue和Deque
  • #ifndef #else #endif条件编译
  • C语言基础语法详解:从入门到掌握
  • 【FreeRTOS】事件标志组
  • Linux文件操作命令
  • QPS说明
  • 提升变电站运维效率:安科瑞无线测温系统创新应用
  • oracle数据库物理结构
  • Python异常处理实战指南:从基础语法到设计哲学
  • windows一键测速DNS并切换
  • MQTT学习资源
  • 极域教师管理CMD命令操作
  • kaggle配置