当前位置:网站首页>6133. Maximum number of packets
6133. Maximum number of packets
2022-08-01 23:09:00 【先生高】
6133. Maximum number of groups
You are given an array grades of positive integers representing the grades of some students in the college.You intend to divide all students into ordered non-empty groups where the order between groups satisfies all of the following conditions:
The total grade of students in group i is less than the total grade of students in group (i + 1), true for all groups (except the last group).The total number of students in the ith group is less than the total number of students in the (i + 1)th group, true for all groups (except the last).
Returns the maximum number of groups that can be formed.
Example 1:
Input: grades = [10,6,12,7,3,5]
Output: 3
Explanation: Here is one possible way to form 3 groups:
- Students in group 1 have grades = [12] , total grade: 12 , number of students: 1
- Students in group 2 have grades = [6,7] , total grade: 6 + 7 = 13 , number of students: 2
- Students in group 3 have grades = [10,3,5] , total grade: 10 + 3 + 5 = 18 , number of students: 3
It can be shown that no more than 3 groups can be formed.
Example 2:
Input: grades = [8,8]
Output: 1
Explanation: Only 1 group can be formed, because if two groups are to be formed, the number of students in each group will be equal.
This question seems difficult, but it is actually confusing. The code to solve the problem is as follows:
int maximumGroups(int* grades, int gradesSize){for(int i=1;i<1000;i++){int a=(i+1)*i/2;if(a>gradesSize){return i-1;}}return 0;}
边栏推荐
- 用virtualenv和Virtualenvwrapper虚拟环境管理工具创建虚拟环境
- C#大型互联网平台管理框架源码:基于ASP.NET MVC+EF6+Bootstrap开发,支持多数据库
- Mini Program Graduation Works WeChat Food Recipe Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template
- drf生成序列化类代码
- 03. GO language variable definition, function
- Calculate the midpoint between two points
- What is CICD excuse me
- JS prototype hasOwnProperty in Add method Prototype end point Inherit Override parent class method
- Error creating bean with name ‘dataSource‘:Unsatisfied dependency expressed through field ‘basicPro
- SRv6 L3VPN的工作原理
猜你喜欢
D - Linear Probing- 并查集
分享10套开源免费的高品质源码,免费源码下载平台
Go 微服务开发框架DMicro的设计思路
Mini Program Graduation Works WeChat Food Recipe Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template
C语言——分支语句和循环语句
【参营经历贴】2022网安夏令营
华为无线设备配置双链路冷备份(AP指定配置方式)
leetcode刷题
小程序毕设作品之微信美食菜谱小程序毕业设计成品(5)任务书
程序员如何优雅地解决线上问题?
随机推荐
编曲软件FL studio20.8中文版功能和作用
Thesis understanding [RL - Exp Replay] - Experience Replay with Likelihood-free Importance Weights
别看了,这就是你的题呀
Jmeter是什么
B. Difference Array--Codeforces Round #808 (Div. 1)
得物客服热线的演进之路
excel vertical to horizontal
Is TCP reliable?Why?
用virtualenv和Virtualenvwrapper虚拟环境管理工具创建虚拟环境
【好书推荐】第一本无人驾驶技术书
美赞臣EDI 940仓库装运订单详解
选择合适的 DevOps 工具,从理解 DevOps 开始
避免使用 <b>、<i>、<s> 和 <u> 标签
y84. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (15)
CF1703G Good Key, Bad Key
PostgreSQL 基础--常用命令
数据库表设计规则
还在纠结报表工具的选型么?来看看这个
程序员如何优雅地解决线上问题?
SQL Server(设计数据库--存储过程--触发器)