博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1056. Mice and Rice (25)
阅读量:4071 次
发布时间:2019-05-25

本文共 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/

你可能感兴趣的文章
linux下的mysql源码安装
查看>>
plsql连接oracle出现ORA-12154: TNS: 无法解析指定的连接标识符
查看>>
oracle 查看库中每个表所占的空间大小
查看>>
流复制中的问题max_connection
查看>>
在mysql中使用模糊查询时,使用中文查询结果不正确问题
查看>>
redhat7修改系统语言
查看>>
启动rabbitmq:ERROR: distribution port 25672 in use on localhost (by non-Erlang process?)
查看>>
Linux下mysql8.0用rpm安装
查看>>
linux下mysql 8.0忘记密码后重置密码
查看>>
mysql学习笔记(一)
查看>>
mysql学习笔记(二)
查看>>
mysql学习笔记(三)
查看>>
mysql学习笔记(四)
查看>>
mysql学习笔记(五)
查看>>
mysql学习笔记(六)
查看>>
iOS 微信SDK1.8.6后需要UniversalLink解决方案及采坑记录
查看>>
iOS 异形tabBar, 中间item凸起
查看>>
swift中单例的创建及销毁
查看>>
Swift中NSRange和Range的转换
查看>>
获取App Store中App的ipa包
查看>>