#赫海[超话]# [ NEWS|NOW. ]
220629 NOW. 电台简介更新:
每周三, 四, 五 晚上7点
✨东海银赫的DE Show✨️
和fromis_9 圭俐 知宣一起进行
带着新曲 'Stay This Way'
来找我们的充满魅力的fromi
新专辑全曲公开
知宣的主特技)
asmr问答也会做一下
第2次访问DE Show✌️
圭俐知宣的甜蜜默契
如果想以直播一起度过的话
星期三 晚上7点 来DE Show玩吧♂️
220629 NOW.
每周三, 四, 五 晚上7点
✨东海银赫的DE Show✨️
和fromis_9 圭俐 知宣一起进行
带着新曲 'Stay This Way'
来找我们的充满魅力的fromi
新专辑全曲公开
知宣的主特技)
asmr问答也会做一下
第2次访问DE Show✌️
圭俐知宣的甜蜜默契
如果想以直播一起度过的话
星期三 晚上7点 来DE Show玩吧♂️
1601. Maximum Number of Achievable Transfer Requests
We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.
You are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi.
All buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in. For example if n = 3 and two employees are leaving building 0, one is leaving building 1, and one is leaving building 2, there should be two employees moving to building 0, one employee moving to building 1, and one employee moving to building 2.
Return the maximum number of achievable requests.
解题重点:
1. 数据总量不大,可以回溯+枚举
2. 数组 delta 记录每一栋楼的员工变化量,变量 cnt 记录被选择的请求数量。
3. 对于第pos 个请求 [x,y],如果选择该请求,那么就需要将 delta[x] 的值减 11, delta[y] 的值加 11,cnt 的值加 11
4. 修改 delta 的同时维护 delta 中的 0 的个数,记作zero,初始值为 n。如果 delta[x] 增加或减少前为 0,则将 zero 减 1;如果delta[x] 增加或减少后为 0,则将zero 加 1。
We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.
You are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi.
All buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in. For example if n = 3 and two employees are leaving building 0, one is leaving building 1, and one is leaving building 2, there should be two employees moving to building 0, one employee moving to building 1, and one employee moving to building 2.
Return the maximum number of achievable requests.
解题重点:
1. 数据总量不大,可以回溯+枚举
2. 数组 delta 记录每一栋楼的员工变化量,变量 cnt 记录被选择的请求数量。
3. 对于第pos 个请求 [x,y],如果选择该请求,那么就需要将 delta[x] 的值减 11, delta[y] 的值加 11,cnt 的值加 11
4. 修改 delta 的同时维护 delta 中的 0 的个数,记作zero,初始值为 n。如果 delta[x] 增加或减少前为 0,则将 zero 减 1;如果delta[x] 增加或减少后为 0,则将zero 加 1。
#赫海[超话]# [ NEWS|NOW. ]
220128 NOW. 电台简介更新:
爱豆特辑2弹
今天和'fromis_9'一起吧~
新曲'DM' 1位
全曲上榜
初动打破自身的新纪录
最近最火的
fromis_9来参加DE Show了~?
迎来4周年的fromis_9!
时隔4个月超高速回归!
全专歌曲评价走起~
fromi们来了
不看舞蹈的话会很遗憾吧~~~
以零食Quiz为借口的
准备了舞蹈对决,,
支持fromis_9的粉丝们来这里!!
周五 下午5点DE Show
一起度过的话 不行嘛
翻译:唔西迪西
220128 NOW.
爱豆特辑2弹
今天和'fromis_9'一起吧~
新曲'DM' 1位
全曲上榜
初动打破自身的新纪录
最近最火的
fromis_9来参加DE Show了~?
迎来4周年的fromis_9!
时隔4个月超高速回归!
全专歌曲评价走起~
fromi们来了
不看舞蹈的话会很遗憾吧~~~
以零食Quiz为借口的
准备了舞蹈对决,,
支持fromis_9的粉丝们来这里!!
周五 下午5点DE Show
一起度过的话 不行嘛
翻译:唔西迪西
✋热门推荐