Java Python Computer Science 320SC – (2024)
Programming Assignment 5
Due: Oct 13 2024 (11:59pm)
Academic Integrity
Before attempting to solve the assignment, please read the message below very carefully.
As described on https://academicintegrity.cs.auckland.ac.nz/, you must NOT
Use all or part of another student’s solution to the assignment. Changing variable names or
substituting words in a sentence does not make it your solution.
Allow someone else to complete all or part of the assignment for you.
Solicit answers for the assignment on contract-cheating websites such as Chegg.com and
Bartleby.com.
Use code from Internet sources such as StackOverffow or generative-AI tools such as ChatGPT.
You are encouraged to learn from Internet sources and tools, but you need to come up
with your own implementation of the code to show your learning.
Allow another student to copy all or part of your solution to the assignment.
Do all or part of an assignment for someone else.
Share code that can lead to the solution of an assignment.
Post the assignment anywhere online or share it with anyone else. The assignment material
is copyrighted and sharing or posting them online violates our copyright.
Post your solution online on public websites. Your online solutions will encourage other
students to copy your solution. Private GitHub repositories and other private online storage
drives are acceptable, and you can also share your solution privately with prospective
employers.
Reuse your own work unless discussed otherwise with the lecturer.
Leave your computers, devices, and belongings unattended — you must secure these at all
times to prevent anyone having access to your assessments or solutions.
Last year, out of 218 students, there were 11 misconducted cases found on A5 - Task 1. We kept the
submissions from the last few years to run MOSS at https://theory.stanford.edu/~aiken/moss/.
I hope that there will be no cases this year!
1Requirements
This 5th assignment lets you get familiar with dynamic programming design and development. It is
worth 5% of your total course marks. We would like you to implement efffcient dynamic programming
algorithms for two tasks: Task 1: Finding partner and Task 2: Killing enemies.
An excessive number of submissions (over 10) for a particular problem will accrue a 20% penalty per that
problem if you eventually solve it. Therefore, please write a bruteforce algorithm and test your
dynamic programming version with your own generated inputs at scale before submitting
to the automated marker.
We only accept Python programs that use built-in packages (i.e. packages that do not require pip
install).
1 Task 1: Meet your partner at skyscraper
1.1 Problem description
You are standing at the ground ffoor and your partner is waiting at the top ffoor of a skyscraper. You
will have to use an algorithmically designed lift L to reach your partner. The lift L is designed in the
manner that if you use the lift at the ffoor i, you are able to reach any ffoor from i + 1 to i + L[i] where
L[i] is a positive integer that presents the capacity of the lift at the i-th ffoor. Each time you use the
lift costs $1.
Assume that the skyscraper has n ffoors and you are at the ffoor 0. Your partner is at the ffoor n − 1
and waiting for you to see the sky view. The lift information L[i] for 0 ≤ i < n is available at the
ground ffoor. Write a function to return the minimum cost, i.e. the number of time using the lift, to
r 320SC、Python each your partner.
O(n) solutions are preferred since we have set the running time limit on the automarker.
1.2 Test case description
Your input will be a sequence of n integers, each value per line corresponding to the lift information
L[i] (e.g. the capacity of the lift) on the i-th ffoor. The ffrst line is for the 0-th ffoor. The last line is
for the (n − 1)-th ffoor, which is a redundant information :-). Your output will be an integer.
There are 4 test cases.
1. A trial test case of n = 10 has no mark.
2. A test case of n = 100, 000 and has 1 mark.
3. A test case of n = 1000, 000 and has 2 marks.
2Sample Input 1:
Sample Output 1:
1
You only need to use the lift once since L[0] = 8 is sufffcient to get you to the 4th ffoor.
Sample Input 2:
Sample Output 2:
2
You only need to use the lift twice. The ffrst one with L[0] = 2 to the 1st ffoor, and L[1] = 5 is sufffcient
to get you to the 4th ffoor.
32 Task 2: Arrange tanks to eliminate enemies
2.1 Problem description
You have a queue of n tanks hidden in a forest. Due to the UAV of enemies, only 1 tank is used per
day, and the used tank can only be taken from the front or rear of the queue for some security reasons.
Each tank has a number indicating the number of potential units the tank can eliminate. Since tanks
are hurrily queued up during the night, you cannot organize the tank in the good order to use. Instead,
you have a queue of n values, each reffects the number of potential eliminated units for each tank in
the queue.
Since the war is more and more severe, the number of potential eliminated units dramatically increases
day-by-day. Let the labels of the number of eliminated units from n tanks in the queue be t1,t2, . . . ,tn.
In the i-th day, the used tank k will eliminate i ∗ tk units.
As a commander, for each day, your task is to give an order 1 or 0 corresponding to whether the front
or the rear tank in the queue is used. Write a program to compute the best order of using n tanks for
n days to eliminate maximum number of enemies’ units.
Since there might be several orderings that output the same number of eliminated units, you would
need to output the maximum number of eliminated units only.
You might see that the best solution runs in O(n
2
) time asymptotically. However, a program with low
memory usage (e.g. O(n)) is preferred since the automarker has limited resources, and we have set the
running time limit on the automarker.
2.2 Test case description
Your input will be a sequence of n integers, each value per line i corresponding to the amount of eliminated
units of the tank ti
. The ffrst and last lines correspond to the front and rear tanks, respectively.
Your output is an integer in range [0..2
31
] corresponding to the maximum number of eliminated units.
There are 2 test cases.
1. A trial test case of n = 10 has no mark.
2. A test case of n = 10, 000 has 2 marks.
4Sample Input 1:
Sample Output 1:
128
The order is {1, 0, 0, 1, 1}, and the maximum number of detroyed units is 4 * 1 + 10 * 2 + 4 * 3 + 8 *
4 + 12 * 5 = 128. Note that for the last tank (#3), any order of 1 or 0 does not matter.
Sample Input 2:
Sample Output 2:
261
The maximum number of detroyed units is 261 and the order is {1, 1, 1, 0, 0, 0, 0, 1}. Note that for the
last tank (#4), any order of 1 or 0 does not matter.
Submission Procedure
Submit your program solutions to https://www.automarker.cs.auckland.ac.nz
相关推荐
Python量化实战:如何用KAMA指标识别市场趋势(附完整代码)
本文详细介绍了如何利用Python实现考夫曼自适应移动平均线(KAMA)指标来识别市场趋势,并提供了完整的代码示例。KAMA通过动态调整灵敏度,有效减少虚假信号并快速响应市场突破,适用于高频交易、日内交易等多种场景。文章还涵盖了参数优化策略和加密货币市场的特殊应用,帮助开发者构建可靠的量化交易系统。
320SC Python/Java
2 4 815 0 -502 1 3 40yes: 5yes: 25Noneyes: 62Submission。
从零构建USRP Python开发环境:避坑指南与性能调优实战
本文详细指导如何从零构建USRP Python开发环境,涵盖跨平台配置、性能调优和问题诊断。重点解析UHD驱动安装、缓冲区优化及benchmark_rate测试,帮助开发者规避常见陷阱,提升USRP设备在Python环境下的运行效率。
讲解 320SC编程、辅导 Python设计程序
employers.install).12the queue.231128261。
Dia TTS:面向任务的语音合成新范式
语音合成(TTS)正从追求‘像人’的通用自然度,转向服务具体人机交互任务的可控性与可靠性。其核心原理在于将语义理解、韵律建模与声学生成解耦为可干预的分阶段流程,并依托任务导向型对话语音库(TOD-SC)实现语境驱动的语调偏移与领域适配。这种设计赋予TTS明确的技术价值:在车载、医疗、嵌入式等强实时、高信任场景中保障端到端低延迟(TTFA≤350ms)、离线鲁棒性及韵律一致性。典型应用场景包括智能硬件语音反馈、老年健康设备播报、工业HMI语音提示等。Dia正是这一演进路径下的代表性实践,凸显了任务导向型TTS
鼓式制动器设计原理与商用车制动系统故障根因分析
鼓式制动器作为传统但高度可靠的机械制动形式,其核心在于结构约束与热-力耦合机制的协同设计。领从蹄式结构通过可控的法向力失衡实现驻车自锁,凸轮驱动则适配气压制动系统的高温耐受需求。制动鼓直径、支承点坐标k值、衬片包角β等参数并非经验取值,而是经热容量核算、挠度控制与磨损梯度验证的刚性边界。在商用车场景中,这些参数直接决定制动跑偏、异常磨损、驻车失效等高频故障的物理根源。本文基于典型商用客车SC6408V的设计说明书,解析鼓式制动器的底层力学逻辑与产线参数复用方法,为制动系统匹配、售后诊断与质量管控提供可落地的
Computer Science 320SC
employers.install).12the queue.231128261。
VS2015与QT界面开发中解决‘ui_xxx.h‘文件类名不一致导致的编译错误
本文详细解析了在VS2015与QT界面开发中,因.ui文件顶层部件objectName与生成类名不一致导致'ui_xxx.h'文件出现'不完整的类型'编译错误的根本原因。通过分步排查,指导开发者统一Qt设计师对象名、自动生成文件类名及代码引用名,并提供强制重新编译UI文件、清理中间文件等解决方案,有效解决此类常见编译问题。
320SC Programming
employers.1install).31]n = 1002and。
Jetson AGX Orin边缘AI实战:用YOLOv8做目标检测,我的环境配置踩坑与优化记录
本文详细记录了在Jetson AGX Orin上部署YOLOv8目标检测模型的环境配置与优化过程。从JetPack版本确认、PyTorch安装陷阱到Torchvision编译技巧,再到YOLOv8部署和系统级优化,提供了完整的实战指南。特别针对边缘AI设备的特性,分享了CUDA加速、内存管理等性能调优经验,帮助开发者高效完成工业级AI应用部署。
【现代人形机器人:从物理建模到大模型驱动的控制与学习】第1章 机器人建模回顾
本章建立读者进行后续控制 / 优化 / 学习工作的数学与计算基础。内容分为三大块:刚体运动学:位姿表示、坐标变换、旋转参数与李代数/李群(指数映射、twist)多关节机构的正/逆运动学:DH 与 POE 两种建模、雅可比矩阵推导、数值/解析逆解方法与奇异性问题约束动力学:拉格朗日公式、牛顿—欧拉递归算法、接触/冲击模型、受约束系统的方程(拉格朗日乘子与互补性条件)每一节同时给出与练习题。假设读者已具备线性代数(矩阵、特征分解、SVD)、多变量微积分与基础力学(牛顿第二定律)知识。
FinBERT2 金融预训练模型实测:320 亿 Token 金融语料,F1 领先大模型 9.7% 起
把一批财经新闻交给通用大模型做情绪判断,"回调其实是利好"这类句子经常判错;再逐条调用商业 LLM 接口,成本又压不下来。**FinBERT** 是熵简科技开源的中文金融领域预训练语言模型,用 320 亿 Token 的金融语料打底,覆盖金融文本分类、情绪分析、向量检索三类高频任务。先看数据。 ## 一屏看完 FinBERT2 的 4 个关键数字 - **320 亿+ Token**:中文金融
打通ZYNQ的任督二脉:AXI_FIFO数据交互全解析
FIFO(First In First Out,先进先出)是一种经典的数据缓冲结构,就像排队买票一样,先来的人先得到服务。时钟域交叉(CDC):连接不同时钟频率的模块数据缓冲:平衡生产者和消费者的速度差异流量控制:防止数据丢失或溢出input clk,// 输入AXI4-Stream接口(从PS到PL)// 输出AXI4-Stream接口(从PL到PS)// 状态指示信号// 定义状态机状态// 数据缓存// 8个深度的缓存// 流水线处理寄存器。
FinBERT2:基于320亿金融语料预训练的专业金融领域双向编码器
FinBERT2是熵简科技推出的第二代金融领域专用双向编码器模型,通过320亿+高质量中文金融语料的深度预训练,有效解决了大语言模型在金融专业场景部署的语义理解瓶颈。作为目前开源中文金融BERT类模型中预训练语料规模最大、性能表现最优的解决方案,FinBERT2在金融文本分类任务上平均超越主流大语言模型9.7%-12.3%,在向量化检索任务上相比BGE-base-zh提升6.8%,为智能投研、风险
【x264编码器】章节1——x264编码流程及基于x264的编码器demo
提供了一种方便的方式来根据指定的配置profile应用相应的设置到 x264 参数结构体上。不同的配置文件类型会对参数结构体进行不同的修改,以满足特定的编码需求。然后是编码器参数,包括帧参考数、最大关键帧间隔、最小关键帧间隔、B 帧数、场景切换阈值等。结构体的成员进行赋值,将其初始化为默认值。之后是一些编码器设置,如去块滤波、CABAC 编码、码率控制方法、参考帧压缩系数等。接下来是一系列与视频属性相关的参数,如色度格式、宽度、高度、宽高比等。然后是一些与日志输出、分析类型、量化矩阵等相关的参数。
Transformers 实战修炼与源码剖析专栏大纲
本专栏以 Hugging Face Transformers 为主线,围绕“能用、会调、敢上线、懂源码”四个目标展开。内容不把理论堆成公式墙,而是用真实或拟真的业务场景驱动:客服分类、合同抽取、知识库问答、模型微调、推理服务、监控告警、源码扩展等。采用“业务痛点 → 三人剧本对话 → 代码实战 → 总结思考”的四段式结构,让读者在动手完成一个个小项目的过程中,逐步理解 Tokenizer、Model、Pipeline、Trainer、Generation、PEFT、Accelerate、Serving等概念
FinBERT2:320亿Token金融语料炼成的中文金融NLP预训练模型,快速上手指南
如果你要做中文金融文本的分类、情绪判断或文档检索,这篇文章用 FinBERT2 的官方实测数据,讲清它解决什么问题、凭什么做得好、如何用两条命令跑起来。 ## 通用模型处理金融文本,你大概率会踩这 3 个坑 用通用大模型给金融新闻做分类时,你会发现"净息差""业绩预告"这类词只是字面,模型抓不住业务含义;做情绪分析时,"谨慎乐观"和"强烈看多"的强度差异分不开,结果还得人工校对。 建文档检索
Python 爬虫实战:爬取 Bing 搜索功能链接(国际搜索引擎数据采集技巧)
在当今数字化信息爆炸的时代,搜索引擎已成为我们获取知识、了解世界的得力助手。Bing,作为全球知名的搜索引擎之一,拥有庞大的数据索引和精准的搜索算法。通过 Python 爬虫技术爬取 Bing 搜索区域的链接信息,不仅能帮助我们快速收集大量有价值的数据,还能为后续的数据分析、内容挖掘等任务提供丰富的素材。
士兰微SC7A20H三轴加速度计在智能穿戴运动检测中的选型与实战
三轴加速度计是智能穿戴设备实现计步、睡眠监测等运动检测功能的核心器件。其工作原理基于MEMS技术感知加速度变化,通过I2C或SPI接口输出数字信号,技术价值在于低功耗、小体积和高精度。在智能手环、手表等场景中,加速度计的数据质量直接影响用户体验。士兰微SC7A20H作为国产MEMS加速度计,凭借低功耗、寄存器兼容性和供应链稳定性,成为智能穿戴运动检测的优选方案。本文深入探讨其硬件设计、驱动配置、算法调优及量产实践,为工程师提供从选型到量产的完整参考。
[QMT和ptrade量化交易小白入门]-121、如何用K-means聚类,每月自动筛选高流动性ETF
本专栏主要是介绍QMT和ptrade的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写200篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步。
pscad IEEE标准系统搭建说明
pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。
Redhawk-SC输入件配置:功耗与热仿真可信度的根基
在芯片物理设计中,功耗签核依赖电热耦合仿真,其核心在于工具输入件的精度与一致性。Redhawk-SC并非黑箱求解器,而是基于工艺模型、物理版图和封装结构三层映射的精密计算引擎。工艺文件(如.lib)需扩展多电压/多温度角与CCS动态电流模型;物理层需确保电源网格、金属厚度与dummy填充完整;封装层则要求.idf几何保真、S参数时域截断及热阻网络手工校准。这些输入件共同决定IR Drop预测精度与热点温度误差——实测表明,未增强的.lib模型可致温差±12℃,而规范配置后误差可压缩至±3.5℃。本文聚焦28
精雕软件(JDpaint) 5.5 绿色版
精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版
Redhawk-SC输入件配置:工艺文件与封装模型的一致性校验指南
电源完整性仿真(PI)的准确性根本取决于EDA工具输入件的物理一致性。工艺文件(如LEF、techfile)定义金属层厚度、方块电阻等底层物理标尺,而封装模型(PKG)必须严格复用同一套标尺构建TSV、RDL、焊球等效电路——二者单位错位、命名不匹配或参数推导失准,将导致IR Drop误差超百毫伏。这种跨域协同本质是工艺厂、设计方与封装厂之间的技术契约。本文聚焦Redhawk-SC场景,系统解析工艺文件三层结构(物理定义/电学建模/封装协同)、封装模型四大支柱(基板/焊球/TSV/RDL),并提供可落地的七
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
OV9734 DATASHEET,完整规格书
OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等
晶圆清洗工艺实战:从RCA到AI预测的全流程指南
摘要 半导体晶圆制造中,清洗工艺是影响良率的关键环节。文章系统分析了四种主流清洗技术:RCA标准清洗(SC-1/SC-2)、兆声波辅助清洗、IPA干燥和低温CO2清洗,重点阐述了其原理、参数配置和应用场景。通过65nm逻辑芯片Cu污染案例,展示了问题诊断与解决方案,并提供了80行Python代码工具,用于清洗液配比计算和时间优化。对比评估显示,兆声波辅助清洗在65nm以下先进制程中表现最优。文章还提出了工艺导入路线图、日常维护要点,并展望了等离子清洗、激光清洗和AI预测等前沿技术方向,为半导体制造工程师提供
别再只会用parallelize了!Spark RDD创建的3种实战姿势(Python版)
本文深入探讨了Spark RDD在Python中的三种高效创建方式,包括parallelize的进阶用法、textFile的大文件处理技巧以及wholeTextFiles的小文件解决方案。通过实战示例和性能优化建议,帮助开发者根据数据特性选择最佳RDD创建策略,提升分布式计算效率。
Deepseek+python - 自动图表生成
请整理并分析上传的数据,生成数据看板,包括标题,不同品牌销售数据柱状图和看板、品牌份额饼图和技术卖点分布条形图。python绘制的图表还比较初级,可以让deepseek生成HTML或Mermaid,在Cherry Studio或Mermaid环境生成更专业的可视化图表。Deepseek不支持直接自动绘制图表,但支持生成图表代码,如python、mermaid、html,支持对图表内容进行修改。请联网搜索2024年小米、比亚迪、特斯拉、奇瑞、吉利、广汽、大众等品牌新能源车的销量,以csv的格式输出。
php判断区号,如何使用PHP或python将区号转换为状态?
制表符分隔的副本/意面,用于将区号映射到州缩写据我所知,它们是正确的,如果您看到任何错误的映射、遗漏或不正确的映射,请留下注释和/或修复它。在201 NJ202 DC203 CT204 MB205 AL206 WA207 ME208 ID209 CA210 TX212 NY213 CA214 TX215 PA216 OH217 IL218 MN219 IN224 IL225 LA226 ON228...
303



被折叠的 条评论
为什么被折叠?



