fork(5) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int ans, sum, x, n, q;
  6.  
  7. int main()
  8.  
  9. {
  10. scanf("%d %d", &n, &x);
  11. sum = 0;
  12. for (int i = 0; i < n; i++)
  13. {
  14. cin>>q;
  15. sum += q;
  16. }
  17. sum = abs(sum);
  18. ans = sum / x;
  19. if (sum % x != 0) ans++;
  20. cout<<ans<<endl;
  21. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
0