codeforces 1041A Heist
electronic a.电子的
heist v.抢劫
in ascending order 升序
indice n.标记
device n.装置设备
staff n.职员
in arbitrary order 任意顺序
pairwise distinct两两相异
题意就是:一个电子商品店被抢劫了,店里面所有的键盘都是从x开始按升序排列的,被抢劫后,还剩下n个键盘,(店员不记得x,也不知抢劫前商店里键盘的数量),求被偷的键盘的最小数
分析:要使被偷的键盘数最少,就从剩下的键盘里找到最小的数和最大的数,使被偷的键盘的数都从这里面产生,这样被偷的键盘才能保证最小
输出 max-min+1-n
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main ()
{
int a[],n;
while(~scanf("%d",&n))
{
for(int i=;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d\n",a[n-]-a[]+-n);
}
return ;
}
codeforces 1041A Heist的更多相关文章
- Codeforces Round #509 (Div. 2)
咕咕咕了好多天终于有时间写篇博客了_(:з」∠)_ 打网赛打到自闭的一周,终于靠这场CF找回了一点信心... 1041A - Heist \(ans=max\left \{ a_i \right \} ...
- Codeforces Round #509 (Div. 2) A. Heist 贪心
There was an electronic store heist last night. All keyboards which were in the store yesterday were ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- python自学第9天,装饰器
装饰器:本质是函数(装饰其它函数) 就是为其它函数添加附加功能 原则:1.不能修改被装饰函数的源代码 2.不能修改被装饰的函数的调用方式 实现装饰器知识储备: 1.函数即变量 2.高阶函数:a.把一个 ...
- 剑指Offer 47. 求1+2+3+...+n (其他)
题目描述 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C). 题目地址 https://www.nowcod ...
- python3+requests:接口自动化测试(二)
转载请注明出处:https://www.cnblogs.com/shapeL/p/9188495.html 前言:上篇文章python3+requests+unittest:接口自动化测试(一):ht ...
- 【Keil5 MDK】armar工具的基本用法(armar --help)
ARM Librarian, 5.03 [Build 76] - archive creation and maintenance tool Command format: armar options ...
- Linux下查看CPU型号,内存大小,硬盘空间的命令(详解)
1 查看CPU 1.1 查看CPU个数 # cat /proc/cpuinfo | grep "physical id" | uniq | wc -l 2 **uniq命令:删除重 ...
- export 和import使用
在JavaScript ES6中,export与export default均可用于导出常量.函数.文件.模块等,你可以在其它文件或模块中通过import+(常量 | 函数 | 文件 | 模块)名的方 ...
- 渲染标签 - v-text
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title ...
- Python基础:一、编程语言分类
编程语言主要从以下几个角度进行分类: 编译型和解释型 静态语言和动态语言 强类型语言和弱类型语言 编译型语言和解释型语言 编译和解释的区别是什么? 编译器是把源程序的每一条语句都编译成机器语言,并保存 ...
- Java 中int、String的类型转换
int -> String int i=12345;String s="";第一种方法:s=i+"";第二种方法:s=String.valueOf(i); ...
- HBase各版本对Hadoop版本的支持情况
转载自:http://blog.csdn.net/sunny05296/article/details/54089194 安装HBase时,要考虑选择正确的Hadoop版本,否则可能出现不兼容的情况. ...