【USACO 1.3】Barn Repair
1.3 USACO Repair
2023-09-11 14:19:25 时间
贪心,去掉最大的min(m,c)-1个间隔
/******************************************* TASK: barn1 LANG: C++ Created Time: 2016/9/9 14:36:17 *********************************/ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[201],d[201]; int main(){ freopen("barn1.in","r",stdin); freopen("barn1.out","w",stdout); int m,s,c; cin>>m>>s>>c; for(int i=0;i<c;i++)cin>>a[i]; sort(a,a+c); int ans=a[c-1]-a[0]+1; for(int i=1;i<c;i++) d[i]=a[i]-a[i-1]-1; sort(d+1,d+c); for(int i=1;i<min(m,c);i++) ans-=d[c-i]; cout<<ans<<endl; }
相关文章
- u-boot-1.3.4 移植到S3C2440
- [AngularJS - thoughtram] Exploring Angular 1.3: Binding to Directive Controllers
- Atitit 常用数据类型有哪些 目录 1.1. 数值类型 整数 小数 自增整数1 1.2. 货币类型1 1.3. 字符类型 字符串2 1.4. 日期/时间类型 时间戳2 1.5. Ur
- Atitit 网关协议cgi wsgi fcgi fastcgi 目录 1.1. CGI(common gateway unterface)1 1.2. 2.1 WSGI:1 1.3. 2.3
- Atitit 各种设计图纸分类 目录 1. Atitit 常见软件设计图纸总结2 1.1. Uml系列图纸2 1.2. Er图 req需求图2 1.3. Parametric diagr
- Atitit 读取音频音乐文件的bpm 目录 1.1. Librosa是一个用于音频、音乐分析、处理的python工具包,1 1.2. bpm.py1 1.3. Echo2 1.4. Cod
- Atitit 2016 技术趋势与没落技术 目录 1.1. 流水线 即代码通过编码而非配置CI/CD运行工具的方式,来定义部署 流水线1 1.2. 将APIs当作产品1 1.3. 无服务器架构
- Atitit office Ooxml excel标准的主要内容 目录 1.1. 物理存储 zip+文件夹包+xml1 1.2. Package Structure1 1.3. 内容部分1
- Atitit 短信验证的漏洞 目录 1.1. APP读取短信1 1.2. 手机上访问的业务来说,短信验证码就没那么独立了1 1.3. 短信保管箱”1 1.4. 自动把短信备份到云端的功能。2
- Atitit 人员评价能力模型 目录 1.1. 深度、大局观、1 1.2. 影响力, 影响力 分享1 1.3. 业务洞察力 价值识别1 1.4. 视野 战略和人才 专业1 1.5.
- Atitit 编程语言的类型系统 目录 1.2. 动态类型语言(Dynamically Typed Language):1 1.3. 静态类型语言(Statically Typed Languag
- Atitit 代码的导航 1.1.代码的层次导航 语句 函数方法 类 包 1.2.4.4. 代码可视化 流程图 一个方法内,多个代码行的关系图 语句to方法2 1.3.4.5. 类图 类结构
- Atitit 软件开发方法论 attilax著 艾龙 著 1. 1.3 软件工程方法 软件工程方法论分为软件开发方法论和软件组织方法论两个部分。1 2. 软件开发方法的演进 SP DOP PAM
- Atitit 传感器之道 1. 视觉传感器 摄像头1 1.1. 一、光线传感器:1 1.2. 二、距离传感器:1 1.3. 第一种是震动传感器。4 1.4. 第二种是声响传感
- Atitit 异常处理之道 attilax著.docx 1. 概念2 1.1. 异常机制的设计原理2 1.2. Atitit.异常机制的设计原理.docx java2 1.3. JVM看Exc
- Atitit 建设自己的财政体系 attilax总结 1.1. 收入理论2 1.2. 收入分类2 1.3. 2 1.4. 非货币收入2 1.5. 2 1.6. 降低期望2 1.7.
- Golang 1.3 发布时间。最终找到地方下载。
- Android Studio报错:Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.61)