当前位置:网站首页>[Small Coder Study Room] [NOI Online 2020-2 Beginner Group] Finished: Abominable precision will make you burnt
[Small Coder Study Room] [NOI Online 2020-2 Beginner Group] Finished: Abominable precision will make you burnt
2022-08-08 14:03:00 【small coders】
Minds
- It's a sad story when you're delusional about adding together several inexhaustible and rounded decimals to act as a distributive law, because the abominable precision will make you burnt...
label
- Greedy, binary search
topic address
- [NOI Online #2 Starter Group] not done
- https://www.luogu.com.cn/problem/P6473
Title description
Input format
The three integers n, L, and v in the first line respectively represent the number of types of magic, the length of the hillside, and the speed of Sisyphus.
The second line contains n integers.The ith integer a_i represents the position of the ith magic effect.(1<i<n)
An integer q in the third line represents the number of queries from Zeus.
The next q lines contain an integer per line, and the integer t_i in line i represents the ith query from Zeus.(1<i<n)
Output format
Output q lines, each line has exactly one integer, and the integer in line i corresponds to the answer to the i-th query.(1≤i≤q)
If Zeus cannot make Sisyphus use more years than t_i anyway, output −1.
Sample input and output
Enter #1
3 6 33 5 141345
Output #1
012-1
Instructions/Tips
Solution
Little Coder Problem Solution 1
- One AC
void coder_solution() {// Improve the efficiency of cin and coutios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);int n, l;double v;cin >> n >> l >> v;vector a(n);vector b(n);for(int i = 0; i < n; ++i) {cin >> a[i];}sort(a.begin(), a.end(), greater());b[0] = a[0] / v;for(int i = 1 ; i < n; ++i) {a[i] += a[i - 1];b[i] = a[i] / v;}int q, t;cin >> q;double T = l/v;int cnt;for(int i = 0; i < q; ++i) {cin >> t;if(T > t) {cout << 0 << endl;} else {cnt = upper_bound(b.begin(), b.end(), t - T) - b.begin();if (cnt >= n) {cout << -1 << endl;} else {cout << cnt + 1 << endl;}}}}
边栏推荐
猜你喜欢
【个人总结】2022.8.7周结
华为云弹性云服务器ECS使用【华为云至简致远】
【黑马早报】巴菲特罕见巨亏近3000亿;周鸿祎回应360不能卸载;三亚倡议酒店不变相提高房价;首个国产抗新冠口服药定价不超300元...
译文推荐|深入解析 BookKeeper 协议模型与验证
京东三面惨遭被虐,关于redis,高并发,分布式,问懵了
Implementation of FIR filter based on FPGA (1) - using fir1 function design
你是什么时候对深度学习失去信心的?
shell正则表达式,三剑客grep命令
Review: What is the pre-approval of autumn recruitment?What is an ordinary autumn move?It's all recruitment, why do you need to set these two recruitment time periods?
sample函数—R语言
随机推荐
清华|GLM-130B:一个开放的双语预训练模型
南非 KMP 媒体集团实施了 DMS(文档管理系统)使流程数字化,员工可以再次专注于他们的实际任务,提供了效率
window停掉指定端口的进程
HackTheBox | Horizontall
【干货】交换机的接口类型完全实物了解
暗恋云匹配匿名交友聊天系统开发
R语言ggpubr包的ggsummarystats函数可视化分面箱图(通过ggfunc参数和facet.by参数设置)、添加描述性统计结果表格、palette参数配置不同水平可视化图像和统计值的颜色
synchronized修饰类的注意事项
“自降估值”3个亿的咖啡独角兽要IPO了
非科班毕业生,五面阿里:四轮技术面+HR一面已拿offer
Tsinghua | GLM-130B: An Open Bilingual Pre-training Model
彻底了解什么是POE交换机!!!
更改默认打开应用程序设置
Thesis understanding: "Self-adaptive loss balanced Physics-informed neural networks"
Verilog HDL Bits training 09 grammar foundation
良心到难以置信的网站推荐第7期丨全程干货
sample function—R language
「复盘」面试BAMT回来整理398道高频面试题,助你拿高薪offer
【低代码】1405- 浅谈低代码平台远程组件加载方案
【LeetCode】761. 特殊的二进制序列