首页 > 其他分享 >Computer Science 320 S2

Computer Science 320 S2

时间:2024-08-12 12:38:41浏览次数:9  
标签:Computer Science number 320 intervals input Output Problem

Computer Science 320 S2  (2024)

Programming Assignment 2

Due: August 9th (11:59pm)

Requirements

This assignment requires you to write five efficient algorithms that processes intervals.  At least three of them should be implemented via some type of greedy algorithm. It is worth 5% of your total course marks.

All five programs have the same input and output format. The input will begin with an integer n ≤ 1000 denoting how many testcases. This is followed by n lines of an even number 2m of whitespace separated integers:

a1  b1  a2  b2  a3  b3   . . .  am   bm

Each pairs [ai , bi] denotes a closed interval where it is guaranteed that ai  ≤ bi  for 1 ≤ i ≤ m.  The output will be a single integer per line denoting the answer to the following questions.

Problem 1:

Print the sum of the lengths of all intervals.

Problem 2:

Find the smallest gap length between any two non-overlapping intervals.  If no gaps then output the range of the set.

Problem 3:

Determine the maximum number of non-overlapping intervals.

Problem 4:

Find the maximum number of intervals that overlap at a single point (on x-axis).

Problem 5:

Compute the largest contiguous interval obtained by taking a union of some of the input intervals.

Submission

These problem requirements will each be worth 1 marks.  Sumbit diferent solutions to the computer science automarker https://www.automarker.cs.auckland.ac.nz/. For this assignment you need to use the Python programming language and can submit up to 8 times for each problem before occuring a 20% penalty.

Example Input/Output Input:

4

1  3  0  2  3  4

0  3  1  2  1  3  4  4

0  2  3  4  5  6  3  6  2  4

1  1  1  2  1  3  1  4  1  5

Output 1

Output 2

Output 3

Output 4

Output 5

5

1

2

2

4

6

1

2

3

3

9

1

3

3

6

10

4

1

5

4

 

标签:Computer,Science,number,320,intervals,input,Output,Problem
From: https://www.cnblogs.com/vx-codehelp/p/18354726

相关文章

  • JAK抑制剂焕发“第二春”:Science双发、新药获批、国产爆发
    激酶新发现:JAK激酶介导细胞因子相关的信号通路,具有细胞增殖、分化、凋亡及免疫调控作用。JAK抑制剂潜力巨大,用于自身免疫性疾病、风湿性关节炎等领域。Science重磅新发现,JAK抑制剂联合免疫检查点抑制剂,能够逆转T细胞耗竭,增加抗肿瘤T细胞和NK细胞数量,显著增强PD-1抑制剂治......
  • 文心一言 VS 讯飞星火 VS chatgpt (320)-- 算法导论22.3 12题
    十二、证明:我们可以在无向图G上使用深度优先搜索来获得图G的连通分量,并且深度优先森林所包含的树的棵数与G的连通分量数量相同。更准确地说,请给出如何修改深度优先搜索来让其给每个结点赋予一个介于1和k之间的整数值v.cc,这里k是G的连通分量数,使得u.cc=v.cc当且仅当结点u和结......
  • P3200 [HNOI2009] 有趣的数列
    哇,太恶心了思路首先我们将题意简化,简化后为对于任意一个偶数位所填数必然大于等于自己的下标,那么考虑填数,如果填的偶数比奇数多,那么此时要么填尽偶数后失败,或者下一个位置填奇数就炸,比如偶数刚好多一个,那么必然有一个偶数放在了奇数位,那么本来下一个要填的偶数往前移了一个,导致......
  • D39 2-SAT P3209 [HNOI2010] 平面图判定
    视频链接:D392-SATP3209[HNOI2010]平面图判定_哔哩哔哩_bilibili   图论(十三)——平面图和对偶图_图论(十三)——平面图和对偶图-CSDN博客P3209[HNOI2010]平面图判定-洛谷|计算机科学教育新生态(luogu.com.cn)#include<iostream>#include<cstring>#incl......
  • 表面贴装型晶体谐振器(汽车电子用):DSX321G/DSX321GK/DSX320GE 的卓越性能
    在汽车电子领域的不断发展与创新中,精准而稳定的频率控制成为保障汽车各项系统高效运行的关键。表面贴装型晶体谐振器/MHz带晶体谐振器,特别是DSX321G、DSX321GK和DSX320GE系列,以其出色的性能和独特的特点,在汽车电子系统中发挥着至关重要的作用。一、汽车电子对晶体谐振......
  • 【转载】科研写作入门 —— 聊聊Science Research Writing for non-native Speakers o
    原地址:https://zhuanlan.zhihu.com/p/623882027平行侠:今天我们聊一聊ScienceResearchWritingfornon-nativeSpeakersofEnglish这本书,我博士毕业发的TIP论文就是看了这本书之后才写出来的,我太爱这本书了,请你给我们介绍一下吧。AI:非常高兴听到您对这本书的好评!《S......
  • (reading report)Careers in Science and Engineering A Student Planning Guide to G
    Chapter1Whatareyourcareergoals? howwelldoyourownskillsandpersonalitymatchthecareeryouimagine?面对新问题、新难题或新需求的挑战,你是否感到兴奋?自然世界的复杂性促使人们去理解它吗?如果是这样的话,科学和工程的学习——尽管严格——将为你提供实......
  • jsp“宠爱”宠物医院管理系统43208
    jsp“宠爱”宠物医院管理系统43208本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表项目功能医生,客户信息,诊疗记录,化验记录,疫苗记录,美容记录,购买记录,宠物商品,科室信息,美容信息,疫苗信息,宠物分类开......
  • Oracle归档日志异常增长问题的排查过程 转载 : https://blog.csdn.net/3moods/article
    Oracle归档日志是Oracle数据库的重要功能,用于将数据库的重做日志文件(RedoLog)保存到归档日志文件(ArchiveLog)中。归档日志的作用是提供数据库的备份和恢复功能,以及支持数据库的持续性和数据完整性。当数据库处于归档模式时,数据库引擎会将已经写满的重做日志文件保存到归档日志文件......
  • 亲测有效!!![INS-32025] 所选安装与指定 Oracle 主目录中已安装的软件冲突。
    找到安装包下“\stage\cvu\cvu_prereq.xml”,复制一份,然后,打开这个xml,删除<CERTIFIED_SYSTEMS></CERTIFIED_SYSTEMS>之间的全部内容。原文件代码:<SPACE> <LOCVAR="CRS_HOME"SIZE="3.59"UNIT="GB"SEVERITY="IGNORABLE"......