Problem Preparation
来源:互联网 发布:外汇mt4软件下载 编辑:程序博客网 时间:2024/06/05 04:45
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:
- The number of problems should lie between 10 and 13 (both inclusive).
- The difficulty scores of the easiest problems (that is to say, the problems with the smallest difficulty scores) should be equal to 1.
- At least two problems should have their difficulty scores equal to 1.
- 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
891 2 3 4 5 6 7 8 9101 2 3 4 5 6 7 8 9 1011999 1 1 2 3 4 5 6 7 8 911999 1 3 5 7 9 11 13 17 19 211015 1 13 17 1 7 9 5 3 11131 1 1 1 1 1 1 1 1 1 1 1 2102 3 4 5 6 7 8 9 10 111015 1 13 3 6 5 4 7 1 14
Sample Output
NoNoYesNoYesYesNoNo
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.
题意,给出一行数字
要求
数字个数在10到13之间
排列后两相邻数字之差的绝对值不大于2(注意如果两个相邻的数有一个是最大的那么不做要求且最大的数有且只有一个)
同时这列数最小值是1且1至少有2个
#include<bits/stdc++.h>using namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int a[150]; int t=0; int ma=0; for(int i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]==1) t++; } if(n<10||n>13)//长度限制 printf("No\n"); else { sort(a,a+n); if(a[0]!=1||t<2||a[n-2]==ma)//最大值只有一个1的个数大于2 printf("No\n"); else { for(int i=n-2;i>=0;i--) { a[i]=a[i]-a[i-1]; if(a[i]>2)//绝对值小于2限制 { printf("No\n"); t=-5; break; } } if(t!=-5) printf("Yes\n"); } } } return 0;}
- Problem Preparation
- Problem Preparation
- Problem Preparation
- Problem Preparation T
- ZOJ 3959 Problem Preparation
- ZOJ 3959 Problem Preparation 【】
- zoj 3959 Problem Preparation
- ZOJ3959-Problem Preparation
- ZOJ 3959Problem Preparation
- Preparation
- Problem Preparation for HTML to TXT
- Effective preparation
- webex preparation
- Preparation for OpenGL programming
- SCEA preparation 1
- Business Objects Certification Preparation
- Preparation and Practice
- Google Interview Preparation
- python初步学习知识点1
- mysql删除匿名用户
- Cookie的setPath(),和setDomain()方法
- 常见自动机综述
- part-7 共模抑制比CMRR
- Problem Preparation
- part-8 共模抑制比CMRR的影响
- viewpager 轮播框架---只需一行代码
- Unity 简单的特效管理
- Mybatis (Mysql) 分页
- part-9 放大电路直流误差(DC error)
- Android监听网络状态变化
- 约束布局
- java设计模式——工厂模式一