4fd800b3a8 2011-02-23 kinaba: #include <vector> 4fd800b3a8 2011-02-23 kinaba: #include <numeric> 4fd800b3a8 2011-02-23 kinaba: #include <algorithm> 4fd800b3a8 2011-02-23 kinaba: #include <utility> 4fd800b3a8 2011-02-23 kinaba: using namespace std; 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: struct Bonuses 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: vector<int> getDivision(vector<int> points) 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: int sum = accumulate(points.begin(), points.end(), 0); 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: int left = 100; 4fd800b3a8 2011-02-23 kinaba: vector<int> ans(points.size()); 4fd800b3a8 2011-02-23 kinaba: for(int i=0; i<points.size(); ++i) 4fd800b3a8 2011-02-23 kinaba: left -= (ans[i] = points[i]*100/sum); 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: vector< pair<int,int> > poid(points.size()); 4fd800b3a8 2011-02-23 kinaba: for(int i=0; i<points.size(); ++i) 4fd800b3a8 2011-02-23 kinaba: poid[i] = make_pair( -points[i], i ); 4fd800b3a8 2011-02-23 kinaba: sort(poid.begin(), poid.end()); 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: for(int i=0; left--; ++i) 4fd800b3a8 2011-02-23 kinaba: ans[poid[i].second]++; 4fd800b3a8 2011-02-23 kinaba: return ans; 4fd800b3a8 2011-02-23 kinaba: } 4fd800b3a8 2011-02-23 kinaba: };