地址: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

2017浙江省赛 B - Problem Preparation ZOJ - 3959相关推荐

  1. ZOJ4100 浙江省赛16th Problem A

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4100 比赛的时候封榜开始开这题,因为我的愚蠢没有开出来. 查询的最小值不用 ...

  2. 【2016浙江省赛:区间取模】E : Modulo Query | ZOJ - 3940

    2016浙江省赛:E 题 Modulo Query [难度] 4.5/104.5/104.5/10 据说是卡银题?感觉有点难 [题意] F(i,X)={XmodA1i=1F(i−1,X)modAi2≤ ...

  3. 倪文迪陪你学蓝桥杯2021寒假每日一题:1.11日(2017省赛A第9题)

    2021年寒假每日一题,2017~2019年的省赛真题. 本文内容由倪文迪(华东理工大学计算机系软件192班)和罗勇军老师提供. 后面的每日一题,每题发一个新博文,请大家看博客目录:https://b ...

  4. ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 A. Visiting Peking University

    ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 A. Visiting Peking University 题意,一个人去北京旅游,计划待m天,但是其中有一些天交通管制,不能出去,到 ...

  5. 2021浙江省赛题解(A,C,F,G,J,L,M)

    2021浙江省赛题解(A,C,F,G,J,L,M) A.League of Legends 题解 签到题 直接求和判断一下 注意会爆 i n t int int以及相等的情况. 代码 #include ...

  6. 2022浙江省赛、ICPC昆明区域赛 游·寄

    前夜 周六打的浙江省赛.周日昆明区域赛,周五平常作息,早上和爸妈聊天 我说道 金华疫情情况还好,还能出校吃饭,没想到 噩耗马上就来了.金华突然有了几例阳性,其中有一位还是滴滴司机.线上教学的消息已发出 ...

  7. ZUFE 2017院赛 - Problem K: Jelly与狗头人的地下世界 (DP)

    一个简单的DP. 只能往下和往右传递. 对DP不够敏感,打院赛的时候用记忆化搜索过的,浪费不少时间. #include <iostream> #include <stdio.h> ...

  8. 【最短路】【Heap-dijkstra】hihocoder 1587 ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 J. Typist's Problem...

    题意:给你一个串,仅含有a~g,且每个字母只出现最多一次.和一个光标初始位置,以及一个目标串,问你最少要多少的代价变化成目标串. 有五种操作:在光标前添加一个未出现过的字母,代价1. 删除光标前或者光 ...

  9. hihoCoder 1578 Visiting Peking University 【贪心】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)...

    #1578 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for ...

最新文章

  1. Houdini魔法特效制作学习教程
  2. websocket如何区分用户_WebSocket与普通Socket的差异
  3. 华为网赛云数据中心基础原理自测答案
  4. jaca和mysql外卖系统_【项目实战】太强大了,Java外卖点餐初级系统【附源码】...
  5. go的错误处理(异常捕获、处理):defer+recover机制处理错误、自定义异常(自定义错误)
  6. 1001.Reverse Root
  7. 01.elasticsearch metric aggregation 查询
  8. java1.8 新特性
  9. Android程序杀死自己的进程和其他程序进程方法
  10. 倒计时 2 天,2018 中国大数据技术大会(BDTC)报名通道即将关闭(附参会提醒)...
  11. 136 - Ugly Numbers
  12. window.open被浏览器拦截的解决方案
  13. 禁用,元素设置为不可点击
  14. 两种查找bapi的方法
  15. ubuntu16.04安装天气预报软件
  16. 从零搭建 ES 搜索服务(六)相关性排序优化
  17. 想问问大家,使用qt开发的wps安装包是如何做到32位64位系统兼容的
  18. DL for Scratch 读书笔记
  19. 小熊派移植 TencentOS-tiny+M26/EC20+MQTT 对接腾讯云平台IoThub
  20. cadence学习资料整理

热门文章

  1. 2108年计算机二级考试时间,计算机二级office考前10天复习应该做哪些安排逢考必过...
  2. 窗口捕获显示黑屏_win10每次重启黑屏假死
  3. 深度学习(24)随机梯度下降二: 常见函数的梯度
  4. iPad连android热点掉线,苹果终于承认,iOS 13有这个问题,网络断连的原因找到了...
  5. JAVA_WEB--jsp语法
  6. Windows驱动开发VXD/WDM/WDF/DDK/WDK的联系和区别
  7. uCOS-II中的OS_CPU.h,OS_CPU_A.s,OS_CPU.c
  8. Microwindows及基于Nano-X的简单程序开发
  9. asp.net 中ashx、axd的区别
  10. Python矩阵的用法(使用numpy)