Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     int n;
  6.     scanf("%d", &n);
  7.     int a[n];
  8.     for (int i = 0; i < n; i++)
  9.     {
  10.         scanf("%d", &a[i]);
  11.     }
  12.  
  13.     int b[n];
  14.     for (int i = 0; i < n; i++)
  15.     {
  16.         scanf("%d", &b[i]);
  17.     }
  18.  
  19.     int res = 0;
  20.     for(int i = 0; i < n; i++)
  21.     {
  22.         if (a[i] > b[i])
  23.             res += a[i];
  24.  
  25.         else if (b[i] > a[i])
  26.             res += b[i];
  27.  
  28.         else if (b[i] == a[i])
  29.             res += b[i];
  30.  
  31.     }
  32.     printf("%d", res);
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement