Advertisement
dmkozyrev

216.cpp

May 14th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <queue>
  3.  
  4. int main() {   
  5.     int n; scanf("%d", &n);
  6.    
  7.     std::priority_queue<int> q;
  8.    
  9.     int v;
  10.     while (n--)
  11.         scanf("%d", &v), q.push(v);
  12.        
  13.     int a, b, count_unique = 0;
  14.     while ((a = q.top(), q.pop(), a) && (b = q.top(), q.pop(), b))
  15.         q.push(a-1), q.push(b-1), ++count_unique;
  16.        
  17.     printf("%d", count_unique);
  18.    
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement