本文共 823 字,大约阅读时间需要 2 分钟。
传送门 :
英语不好,所以读起来很吃力,好久才弄明白第一行11个数是编号从0-10的重量 而不是对应下方随机编号的.
AC代码
#include #include #include #include #include #include #include #include using namespace std;struct player{ int id,rank,weight;};void solution(vector ans,int NG){ if(ans.size()==1){ ans[0]->rank = 1; return ; } int len = (int)ans.size(); int x= ans.size()%NG==0?len/NG:len/NG+1; vector nextMath; int i = 0,j; while (i weight>b->weight; }); for (int k = i+1; k rank = x+1; nextMath.push_back(ans[i]); i = j; } solution(nextMath, NG);}int main(){ int NP,NG,a; scanf("%d %d",&NP,&NG); vector ans; vector weight(NP); for (int i=0; i id = a; ans[i]->weight = weight[a]; } solution(ans, NG); sort(ans.begin(), ans.end(), [](player *a ,player *b){ return a->id id; }); for (int i=0; i rank); } return 0;}
转载地址:http://fqhji.baihongyu.com/