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?s1,?s2, ... ,?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.pswp.cn/news/252810.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/252810.shtml
英文地址,請注明出處:http://en.pswp.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;明明單衣…