Advertisement
dmkozyrev

472.cpp

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