2014年4月14日 星期一

[中譯題目] Codeforces - 401A Vanya and Cards

401 A. Vanya and Cards

時間限制: 每個 test case 1 秒
記憶體限制: 每個 test case 256 M

Vanya 喜歡玩樂! 他甚至用一套特別卡組來玩遊戲。 每張卡有一個特定數字。 此數字可以為正數、負數、或是等於零。只有一個限制,在卡片上數字的絕對值不會超過 x。 The only limit is, the number on each card doesn't exceed x in the absolute value.

Natasha 不喜歡 Vanya 花這麼多時間在玩樂上,所以她把所有卡片都藏了起來。Vanya 非常傷心得找他的卡片,但他只找的到其中的 n 張卡片。Vanya 喜歡平衡,所以他希望找到的卡片上的數字總和能等於零。另一方面,他也對找卡片感到非常疲倦,所以幫幫這個小男孩。
告訴他最少卡需要多少張卡片才能讓總合等於零?

你可以假設一開始 Vanya 每個數字 (從 x 到 -x) 都有無限張的卡片。


Input

第一行有兩個數字 n (1 ≤ n ≤ 1000 找到的卡片數目) 和 x (1 ≤ x ≤ 1000 卡片的最大絕對值) 。
第二行有n個數字,代表找到的卡片。

保證被找到的卡片數字的絕對值不會超過 x。

Output

輸出一個整數,代表問題的答案。

Sample input
3 2 
-1 1 2
2 3 
-2 -2

Sample output
1
2


原文出處

If you want to use (copy, paste or quote) my original article, please contact me through email (autek.roy@gmail.com). If there is any mistake or comment, please let me know. :D

如要使用(複製貼上或轉載)作者原創文章,請來信跟我聯絡 (autek.roy@gmail.com)。如果有發現任何的錯誤與建議請留言或跟我連絡。 : )

沒有留言:

張貼留言

請留下您的任何想法或建議!
Please leave any thought or comment!