Advertisement
Sohila_Elshiref

D. sodium parity sum

Dec 6th, 2022
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. ll n;
  2.     cin >> n;
  3.     ll a[n], x = 0, sumO = 0, sumE = 0;
  4.     for (int i = 0; i < n; i++)
  5.     {
  6.         cin >> a[i];
  7.         if (i >= 0)
  8.             x += a[i];
  9.     }
  10.     for (int i = 1; i < n; i++)
  11.     {
  12.         for (int j = 0; j < n; j++)
  13.         {
  14.             if (a[i] <= a[j])
  15.                 swap(a[i], a[j]);
  16.         }
  17.     }
  18.     if (x % 2 == 0)
  19.         sumE == x;
  20.     else
  21.         sumO == x;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement