Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <numeric>
- #include <cmath>
- #include <map>
- #include <cstring>
- using namespace std;
- int main() {
- while(true) {
- int cities, B;
- cin >> cities >> B;
- if(cities == -1 && B == -1) break;
- vector<int> votes(cities);
- vector<int> b(cities, 0);
- int total = 0;
- for(int i = 0; i < cities; i++) {
- cin >> votes[i];
- total += votes[i];
- }
- sort(votes.begin(), votes.end());
- int m = -1;
- for(int i = 0; i < cities; i++){
- if(total == 0) break;
- b[i] = ceil(((double )votes[i]*B) / (((double )total)));
- b[i] == 0 ? b[i] = 1: b[i];
- B -= b[i];
- total -= votes[i];
- m=max(votes[i]/b[i], m);
- }
- cout << m << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement