Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- #include <math.h>
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- int main()
- {
- int N;
- scanf("%d", &N);
- int cost = 0;
- int gives = 0;
- for (int i = 0; i < N; i++) {
- int A;
- scanf("%d", &A);
- if (A > 0) {
- cost += A;
- } else if (A < 0) {
- gives += abs(A);
- }
- }
- // Write an answer using printf(). DON'T FORGET THE TRAILING \n
- // To debug: fprintf(stderr, "Debug messages...\n");
- printf("%d\n", gives - cost);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement