Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the absolute value.

Natasha doesn't like when Vanya spends a long time playing, so she hid all of his cards. Vanya became sad and started looking for the cards but he only found n of them. Vanya loves the balance, so he wants the sum of all numbers on found cards equal to zero. On the other hand, he got very tired of looking for cards. Help the boy and say what is the minimum number of cards does he need to find to make the sum equal to zero?

You can assume that initially Vanya had infinitely many cards with each integer number from  - x to x.

Input

The first line contains two integers: n (1 ≤ n ≤ 1000) — the number of found cards and x (1 ≤ x ≤ 1000) — the maximum absolute value of the number on a card. The second line contains n space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed x in their absolute value.

Output

Print a single number — the answer to the problem.

Sample test(s)
Input
3 2 -1 1 2
Output
1
Input
2 3 -2 -2
Output
2
Note

In the first sample, Vanya needs to find a single card with number -2.

In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value.

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std; int main()
{
int n,x;
while(scanf("%d%d",&n,&x)!=EOF)
{
int sum = ,d;
for(int i = ;i <= n;++i)
{
scanf("%d",&d);
sum += d;
}
sum = abs(sum);
int ans = (sum % x == ? sum / x:sum / x + );
printf("%d\n",ans);
}
return ;
}

codeforces 235 div2 A. Vanya and Cards的更多相关文章

  1. codeforces 355 div2 C. Vanya and Label 水题

    C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. codeforces 235 div2 C Team

    题目:http://codeforces.com/contest/401/problem/C 题意:n个0,m个1,求没有00或111的情况. 这么简单的题..... 做题的时候脑残了...,今天,贴 ...

  3. codeforces 235 div2 B. Sereja and Contests

    Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good ...

  4. [codeforces 235]A. LCM Challenge

    [codeforces 235]A. LCM Challenge 试题描述 Some days ago, I learned the concept of LCM (least common mult ...

  5. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  6. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  7. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  8. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  9. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

随机推荐

  1. 数据库——SQL数据单表查询

    数据查询   语句格式 SELECT [ALL|DISTINCT] <目标列表达式> [,<目标列表达式>] … FROM <表或视图名>[,<表或视图名&g ...

  2. 评审other's意见

    评审意见 1.组 a.界面不友好 b.没连数据库 2.组 a.没连数据库 b.无智能匹配当前时间 3.组 a.基本功能实现 b.界面未优化 4.组 ourselves 5.组 a.各反面较为完善 6. ...

  3. servlet编码乱码问题

    继承HttpServlet 重写doGet(HttpServletRequest req,HttpServletResponse resp),doPost()方法 post提交时: protected ...

  4. Oracle Profile 的简单说明

    1. 查看已经有的oracle 的profile 首先profile的解释 我理解为 是一个 简略的配置文件, 跟linux的 bash文件的配置信息类似 bash_profile . select ...

  5. API接口重复提交

    重复提交的几种情况1.利用JavaScript防止表单重复提交 按钮禁用2.利用Session令牌防止表单重复提交 具体的做法:在服务器端生成一个唯一的随机标识号,专业术语称为Token(令牌),同时 ...

  6. ssh中文乱码解决

    在终端执行命令:export LC_ALL=zh_CN.GB2312;export LANG=zh_CN.GB2312是最有效的.=======================1.不管用那种ssh客户 ...

  7. Java之工具类:判断对象是否为空或null

    import java.lang.reflect.Array; import java.util.Collection; import java.util.Map; /** * 判断对象是否为空或nu ...

  8. 详细理解servlet实现的三种方式和生命周期

    阅读目录 开发servlet的三种方式 理解实现servlet接口的方式,理解servlet生命周期 Servlet接口有五个方法 继承GenericServlet 继承HttpServlet 现在很 ...

  9. 99种用Racket说I love you的方式

    99种用Racket说I love you的方式 来源 https://www.tuicool.com/articles/qiyeAz 原文  http://www.soimort.org/posts ...

  10. 【BZOJ1297】[SCOI2009]迷路(矩阵快速幂)

    [BZOJ1297][SCOI2009]迷路(矩阵快速幂) 题面 BZOJ 洛谷 题解 因为边权最大为\(9\),所以记录往前记录\(9\)个单位时间前的.到达每个点的方案数就好了,那么矩阵大小就是\ ...