Codeforces Round #235 (Div. 2) A. Vanya and Cards

OpenSoucre發表於2014-03-12
#include <iostream>
using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    int sum = 0;
    for(int i = 0 ; i <  n ; ++ i){
        int number;
        cin>>  number;
        sum +=number;
    }
    if(sum < 0) sum = -sum;
    cout<<(sum%x ? sum/x+1 : sum/x) <<endl;
}

 

相關文章