Advertisement
MonsterScripter

CodinGame_2023_08_22__13_05_01__reminder_energy.c

Aug 22nd, 2023
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #include <math.h>
  6.  
  7. /**
  8.  * Auto-generated code below aims at helping you parse
  9.  * the standard input according to the problem statement.
  10.  **/
  11.  
  12. int main()
  13. {
  14.     int N;
  15.     scanf("%d", &N);
  16.     int cost = 0;
  17.     int gives = 0;
  18.     for (int i = 0; i < N; i++) {
  19.         int A;
  20.         scanf("%d", &A);
  21.         if (A > 0) {
  22.             cost += A;
  23.         } else if (A < 0) {
  24.             gives += abs(A);
  25.         }
  26.     }
  27.  
  28.     // Write an answer using printf(). DON'T FORGET THE TRAILING \n
  29.     // To debug: fprintf(stderr, "Debug messages...\n");
  30.  
  31.     printf("%d\n", gives - cost);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement