How about this??
def bonuses(points):
a = sum(points)
b = []
c = sorted(points)
c.reverse()
for i in points:
b += [(int)(i*100/a)];
if(sum(b) != 100):
for i in range(100-sum(b)):
b[points.index(c[i])]+=1
return b
In Python
On Oct 1, 9:21 pm, Ziklon - <[email protected]> wrote:
> My solution
>
> #include <vector>
> #include <map>
> #include <set>
> #include <queue>
> #include <stack>
> #include <bitset>
> #include <algorithm>
> #include <functional>
> #include <numeric>
> #include <utility>
> #include <sstream>
> #include <iostream>
> #include <cstdio>
> #include <cmath>
> #include <cstdlib>
> #include <cstring>
> #define all(v) (v).begin(),(v).end()
> #define sz size()
> #define REP(i,a,b) for(int i=int(a);i<int(b);i++)
> #define fill(x,i) memset(x,i,sizeof(x))
> #define foreach(c,it) for(__typeof((c).begin())
> it=(c).begin();it!=(c).end();it++)
> using namespace std;
> bool orden(pair<int,int> p, pair<int,int>q){
> if(p.first!=q.first)return p.first>q.first;
> return p.first<q.first;}
>
> class Bonuses {
> public:vector <int> getDivision(vector <int> points) {
> int sum=0;
> int acu=0,cur,N=points.sz;
> vector<int> ans;
> vector<pair<int,int> > vp;
> REP(i,0,N)
> vp.push_back(make_pair(points[i],i));
> sort(all(vp),orden);
> REP(i,0,points.sz)sum+=points[i];
> REP(i,0,points.sz){
> cur=points[i]*100/sum;
> acu+=cur;
> ans.push_back(cur);
> }
> int pos=0;
> while(acu<100){
> ans[vp[pos].second]++;
> acu++;
> pos++;
> }
> return ans;
> }
> //Powered by [Ziklon]};
>
> [ Ziklon - WInfTc ]
--
You received this message because you are subscribed to the Google Groups
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.