2017浙江省赛 B - Problem Preparation ZOJ - 3959

地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3959

题目:

It's time to prepare the problems for the 14th Zhejiang Provincial Collegiate Programming Contest! Almost all members of Zhejiang University programming contest problem setter team brainstorm and code day and night to catch the deadline, and empty bottles of Marjar Cola litter the floor almost everywhere!

To make matters worse, one of the team member fell ill just before the deadline. So you, a brilliant student, are found by the team leader Dai to help the team check the problems' arrangement.

Now you are given the difficulty score of all problems. Dai introduces you the rules of the arrangement:

  1. The number of problems should lie between 10 and 13 (both inclusive).
  2. The difficulty scores of the easiest problems (that is to say, the problems with the smallest difficulty scores) should be equal to 1.
  3. At least two problems should have their difficulty scores equal to 1.
  4. After sorting the problems by their difficulty scores in ascending order, the absolute value of the difference of the difficulty scores between two neighboring problems should be no larger than 2. BUT, if one of the two neighboring problems is the hardest problem, there is no limitation about the difference of the difficulty scores between them. The hardest problem is the problem with the largest difficulty score. It's guaranteed that there is exactly one hardest problem.

The team members have given you lots of possible arrangements. Please check whether these arrangements obey the rules or not.

Input

There are multiple test cases. The first line of the input is an integer T (1 ≤ T ≤ 104), indicating the number of test cases. Then T test cases follow.

The first line of each test case contains one integer n (1 ≤ n ≤ 100), indicating the number of problems.

The next line contains n integers s1s2, ... , sn (-1000 ≤ si ≤ 1000), indicating the difficulty score of each problem.

We kindly remind you that this problem contains large I/O file, so it's recommended to use a faster I/O method. For example, you can use scanf/printf instead of cin/cout in C++.

Output

For each test case, output "Yes" (without the quotes) if the arrangement follows the rules, otherwise output "No" (without the quotes).

Sample Input

8
9
1 2 3 4 5 6 7 8 9
10
1 2 3 4 5 6 7 8 9 10
11
999 1 1 2 3 4 5 6 7 8 9
11
999 1 3 5 7 9 11 13 17 19 21
10
15 1 13 17 1 7 9 5 3 11
13
1 1 1 1 1 1 1 1 1 1 1 1 2
10
2 3 4 5 6 7 8 9 10 11
10
15 1 13 3 6 5 4 7 1 14

Sample Output

No
No
Yes
No
Yes
Yes
No
No

Hint

The first arrangement has 9 problems only, which violates the first rule.

Only one problem in the second and the fourth arrangement has a difficulty score of 1, which violates the third rule.

The easiest problem in the seventh arrangement is a problem with a difficulty score of 2, which violates the second rule.

After sorting the problems of the eighth arrangement by their difficulty scores in ascending order, we can get the sequence 1, 1, 3, 4, 5, 6, 7, 13, 14, 15. We can easily discover that |13 - 7| = 6 > 2. As the problem with a difficulty score of 13 is not the hardest problem (the hardest problem in this arrangement is the problem with a difficulty score of 15), it violates the fourth rule.

思路:

  手速题+2,排序后扫一遍就好

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 #define MP make_pair
 6 #define PB push_back
 7 typedef long long LL;
 8 typedef pair<int,int> PII;
 9 const double eps=1e-8;
10 const double pi=acos(-1.0);
11 const int K=1e6+7;
12 const int mod=1e9+7;
13 
14 int n,a[K],ans;
15 int main(void)
16 {
17     int t;cin>>t;
18     while(t--)
19     {
20         ans=1;
21         cin>>n;
22         for(int i=0;i<n;i++)
23             scanf("%d",a+i);
24         if(n<10||n>13)
25         {
26             printf("No\n");continue;
27         }
28         sort(a,a+n);
29         if(!(a[0]==1 && a[1]==1))
30         {
31             printf("No\n");continue;
32         }
33         for(int i=0;i<n-2;i++)
34         if(a[i+1]-a[i]>2)
35         {
36             ans=0;break;
37         }
38         if(ans)
39             printf("Yes\n");
40         else
41             printf("No\n");
42     }
43     return 0;
44 }

 

转载于:https://www.cnblogs.com/weeping/p/6764487.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/252810.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

jQuery导入代码片段并绑定事件

a.html <div><button class"button" >点我达</button> </div> b.html <html> <head><script type"text/javascript" src"./js/jquery-1.0.1.js"></script><meta http-equiv"Content-Ty…

验证码识别

基于Keras&#xff0c;识别简单的4位字符的验证码。 https://github.com/ypwhs/captcha_break

LinCode落单的数

easy 落单的数 查看执行结果 60% 通过给出2*n 1 个的数字&#xff0c;除当中一个数字之外其它每一个数字均出现两次。找到这个数字。 您在真实的面试中是否遇到过这个题&#xff1f; Yes例子 给出 [1,2,2,1,3,4,3]。返回 4 挑战 一次遍历&#xff0c;常数级的额外空间复杂度…

汉邦高科范俊峰:关于透雾摄像机那点事

慧聪安防网讯 生活在北方的人们&#xff0c;隔三差五就和雾霾来一次亲密接触&#xff0c;雾霾对人们的出行和交通有很大的影响&#xff0c;雾霾笼罩之下&#xff0c;人们出行如果闯红灯、车辆违规行驶发生交通事故&#xff0c;交通监控摄像头只能“雾里看花”&#xff0c;透雾摄…

SpringBoot注解大全(转)

原文链接&#xff1a;[springBoot系列]--springBoot注解大全 一、注解(annotations)列表 SpringBootApplication&#xff1a;包含了ComponentScan、Configuration和EnableAutoConfiguration注解。其中ComponentScan让spring Boot扫描到Configuration类并把它加入到程序上下文。…

祭奠我的2018

提前写这篇文章&#xff0c;是因为深深的感觉到自己的无能 18年伊始&#xff0c;在浪潮干了大半年的我 还沉醉在深深的满足感中&#xff0c;感觉自己对工作游刃有余 那种自大和自我满足感充斥着我的心态 已经变得不会学习了 后来有一次机遇&#xff0c;让我有了跳出舒适的机会 …

工业摄像头传感器尺寸与像元尺寸的关系

http://www.mv186.com/show-list.php?id462 在机器自动化行业检测应用中&#xff0c;工业摄像头是必备的硬件&#xff0c;而图像传感器又是工业摄像头中最最关键核心的东西。图像传感器的尺寸&#xff08;靶面大小&#xff09;&#xff0c;往往直接关系到成像的质量。通常来讲…

CF-798B

B. Mike and stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the fi…

微信小程序倒计时实现

思路&#xff1a;跟一般js倒计时一样&#xff0c;主要在于this的变相传递。 实现效果&#xff1a; wxml文件部分代码&#xff1a; common.js文件 : 引用页JS文件: PS: 1.在data里初始化时间格式&#xff0c;是避免时间加载的第1秒显示为空白&#xff0c;因为setTimeOut是在1s以…

基于Kubeadm的Flannel分析

Flannel概述 Flannel是将多个不同子网&#xff08;基于主机Node&#xff09;通过被Flannel维护的Overlay网络拼接成为一张大网来实现互联的&#xff0c;通过官方的一张网络拓扑图我们可以对其基本原理一目了然&#xff1a; 值得探讨的是&#xff0c;flannel的这个overlay网络支…

sensor的skipping and binning 模式

1、第一种理解 关于sensor的缩放存在两种模式 binning mode 和skip mode skipping mode 就是把想要的数据采集上来 把其余的数据扔掉 如下所示 column skip 2 row skip 2 留下的就是白色的像素 黑色的像素丢掉。 binning mode 就是把相邻的像素合成一个像素&#xff0c;然后再…

5 结构型模式之 - 适配器模式

5 结构型模式之 - 适配器模式 适配器模式的介绍&#xff1a;适配器模式在开发中使用率很高&#xff0c;适配器是将两个不兼容的类融合在一起&#xff0c;它有点像粘合剂&#xff0c;将不同的东西通过一种转换使得它们能够协作起来。例如经常碰到两个不相关的类之间进行交互&…

Android进程保活

凡是做过几年Android开发的&#xff0c;都不能不面对进程保活这一问题。特别是这两年&#xff0c;面对谷歌&#xff0c;国内定制ROM&#xff0c;安全软件等多方围剿的情况下&#xff0c;app在后台保活的难度越来越大&#xff0c;可以说包括QQ、微信在内的所有app&#xff0c;都…

治安卡口摄像机与电警抓拍机之间有什么区别?

接下来小编和大家说说它们有哪些相同和不同的地方&#xff0c;供大家参考。 治安卡口&#xff1a; 卡口摄像机主要是用于城市道路或高速公路出入口、收费站等重点治安监控地段的全天候实时检测与记录收费站、交通或治安检查站等地点。 治安卡口监控系统的前端部分主要由三个单元…

https证书互信解决方案—创建私有CA并申请证书

前言 https相较于http而言有很大的安全性&#xff0c;当我们一个服务开启https并与之通信时&#xff0c;往往需要证书的认证&#xff0c;如果是浏览器访问服务&#xff0c;只要在浏览器内设置信任证书即可&#xff0c;而如果是程序内访问服务&#xff08;如java程序&#xff09…

[转]Unity-移动设备可用的压缩解压缩源码

原文&#xff1a;http://www.manew.com/thread-103250-1-1.html 最近在做客户端数据的分离&#xff0c;不希望对项目有什么影响&#xff0c;也不太想用AssetBundle&#xff0c;太麻烦&#xff0c;就在网上找了找开源的C#压缩算法&#xff0c;找来找去&#xff0c;发现不是不支持…

高亮显示QSS文件

转【作者&#xff1a;一去丶二三里 博客地址&#xff1a;http://blog.csdn.net/liang19890820】 简述 语法高亮是文本编辑器用来显示文本的&#xff0c;特别是源代码&#xff0c;根据不同的类别来用不同的颜色和字体显示。这个功能有助于编写结构化的语言&#xff0c;例如&…

智能识别技术对电子警察设备的影响

电子警察是目前交通管理部门用的最多的一种监控管理系统。这类系统与传统安防的监控设备有很大区别&#xff0c;原先的系统只能抓拍车辆图片&#xff0c;准确率又低所以被交通管理部门慢慢的淘汰了&#xff0c;同业兴创这款最新的设备系统&#xff0c;有它一个很优质的特点就是…

Mybatis缓存配置

pom文件配置: <dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.4.1</version> </dependency> <dependency><groupId>org.mybatis</groupId><artifactId>myba…

初入Linux,M35作业第一弹,500字感想

毕业以后&#xff0c;做过很多工作&#xff0c;一直比较迷茫。来这边上课&#xff0c;其实是我的好同学推荐我来报班的&#xff0c;因为他本身是做运维的&#xff0c;运维前景还可以&#xff0c;而且我对这个也感兴趣。有一种冷&#xff0c;叫你妈觉得你冷&#xff0c;明明单衣…