当前位置:网站首页>【7.8】Educational Codeforces Round 131 (Rated for Div. 2)
【7.8】Educational Codeforces Round 131 (Rated for Div. 2)
2022-07-17 18:28:00 【ZhgDgE】
ALL:6
AC:3
补题:1
D. Permutation Restoration
题意:这里有一个长度为 n ( n ≤ 2 × 1 0 5 ) n(n\leq 2\times 10^5) n(n≤2×105) 数组 a a a , b i = ⌊ i a i ⌋ b_i=\left\lfloor \frac{i}{a_i} \right\rfloor bi=⌊aii⌋ 。
现在给出 b b b ,让你还原出 a a a 。保证一定有解。
题解:Educational Codeforces Round 131 D(贪心)
思路:先推一下公式:由题可知 b i = ⌊ i a i ⌋ b_i=\left\lfloor \frac{i}{a_i} \right\rfloor bi=⌊aii⌋ ,即 b i ≤ i a i < b i + 1 b_i\leq \frac{i}{a_i}<b_i+1 bi≤aii<bi+1 ,即 i b i + 1 < a i ≤ i b i \frac{i}{b_i+1}<a_i\leq \frac{i}{b_i} bi+1i<ai≤bii ,即 a i ∈ [ ⌊ i b i + 1 ⌋ + 1 , ⌊ i b i ⌋ ] a_i\in [\left\lfloor\frac{i}{b_i+1}\right\rfloor+1, \left\lfloor\frac{i}{b_i}\right\rfloor] ai∈[⌊bi+1i⌋+1,⌊bii⌋] 。
问题转化为已知 L i , R i , i ∈ [ 1 , n ] L_i,R_i,i\in[1,n] Li,Ri,i∈[1,n] ,求排列 a i ∈ [ 1 , n ] a_i\in[1,n] ai∈[1,n] 满足 L i ≤ a i ≤ R i L_i\leq a_i\leq R_i Li≤ai≤Ri ,类似于一个任务调度问题。因为排列元素不相同,我们可以枚举 1 ∼ n 1\sim n 1∼n 来分配。每次枚举到 i i i 时找出所有 L j ≤ i L_j\leq i Lj≤i 的区间,并且在这些区间中找到右端点最靠左的分配。
AC代码:https://codeforces.com/contest/1701/submission/163997864
边栏推荐
- 深度学习从入门到放弃100天挑战
- Galaxy Kirin V10 arm offline installation of portal
- [Yugong series] July 2022 go teaching course 012 forced type conversion
- Onvif protocol related: 2.1.2 get screenshot URL in none mode
- onvif协议相关:2.1.2 none方式获取截图url
- onvif协议相关:3.1.4 Digest方式获取流地址
- [pyGame learning notes] 7 event
- STL string复制比较
- LeetCode 0117. Populate the next right node pointer II of each node
- Flutter 使用 AnimatedSwitcher 做场景切换
猜你喜欢

jvm自学总结
![Codeforce:a. difference operations [mathematical thinking]](/img/be/28bcb5dd8b9a36f2955f1912f289a3.png)
Codeforce:a. difference operations [mathematical thinking]
![[record of question brushing] 13 Roman numeral to integer](/img/44/9eff513ff8eb4109d3f77ed6832ee8.png)
[record of question brushing] 13 Roman numeral to integer

【腾讯蓝鲸】第七届 7·24 运维日节日祝福送上~ 快来许愿~

Forget about postman. Apifox is better

onvif协议相关:4.1.1 WS-Username token方式获取WSUsernameTokenBean

【考研词汇训练营】Day 6 —— eventually,state,create,productivity,stimulate

LeetCode 0565. Array nesting: convert to graph + modify in place の optimization

Azkaban installation documentation

使用case语句时会产生锁存器的情况
随机推荐
[micro Service ~ advanced] configuration center practice
LeetCode 0117. 填充每个节点的下一个右侧节点指针 II
Security measures for tcp/ip protocol vulnerabilities
【码蹄集新手村 600 题】如何使整数逆序
模板虚拟机环境准备
[pyGame learning notes] 7 event
【码蹄集新手村 600 题】针对于字符串的格式化控制,即字符串的宽度与精度
Running node for getting started with eth
A general memory management driver code is sorted out
模块7(王者荣耀商城异地多活架构设计)
如何在MFC中添加一个线程
【码蹄集新手村 600 题】输出时的左对齐,右对齐
How to upgrade Flink job gracefully?
LeetCode 0118. Yanghui triangle
jvm自学总结
XML file parsing
大家好,问一下数据库没开始binlog如何实时同步么,有没有好的方案
Galaxy Kirin V10 arm offline installation of portal
STL string查找子串
C语言进阶——字符函数和字符串函数