Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <numeric>
  5. #include <cmath>
  6. #include <map>
  7. #include <cstring>
  8.  
  9. using namespace std;
  10. int main() {
  11. while(true) {
  12. int cities, B;
  13. cin >> cities >> B;
  14. if(cities == -1 && B == -1) break;
  15. vector<int> votes(cities);
  16. vector<int> b(cities, 0);
  17. int total = 0;
  18. for(int i = 0; i < cities; i++) {
  19. cin >> votes[i];
  20. total += votes[i];
  21. }
  22. sort(votes.begin(), votes.end());
  23. int m = -1;
  24. for(int i = 0; i < cities; i++){
  25. if(total == 0) break;
  26. b[i] = ceil(((double )votes[i]*B) / (((double )total)));
  27. b[i] == 0 ? b[i] = 1: b[i];
  28. B -= b[i];
  29. total -= votes[i];
  30. m=max(votes[i]/b[i], m);
  31. }
  32.  
  33. cout << m << endl;
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement