ZOJ 3959 Problem Preparation
来源:互联网 发布:java eclipse 编辑:程序博客网 时间:2024/06/08 14:48
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.
给定 N 个数,每个数
- 题目数在 10 到 13 题之间,包括 10 题、13 题
- 最简单题目的难度值应为 1
- 至少有两个题的题目难度为 1
- 若将题目难度从小到大排序,相邻题目的难度差不能大于 2 (除了最后一题)。
解题思路
简单模拟,
代码
#include<bits/stdc++.h>using namespace std;const int N = 100 + 10;int n, a[N];bool jug(){ if(n>13 || n < 10 || a[1] != 1 || a[2] != 1) return false; for(int i=2;i<n;i++) if(a[i]-a[i-1] > 2) return false; return true;}int main(){ int T; scanf("%d",&T); while(T--) { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1, a+n+1); printf("%s\n",jug()?"Yes":"No"); }}
- ZOJ 3959 Problem Preparation
- ZOJ 3959 Problem Preparation 【】
- zoj 3959 Problem Preparation
- ZOJ 3959Problem Preparation
- Problem Preparation
- Problem Preparation
- Problem Preparation
- Problem Preparation T
- ZOJ3959-Problem Preparation
- Preparation
- Problem Preparation for HTML to TXT
- ZOJ Problem 1374 Substrings
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1048
- ZOJ Problem Set - 1049
- ZOJ Problem Set - 1051
- 【Summary】——>Web组·Week3
- CSDN-markdown编辑器使用教程存档
- Spring AOP(1)- 前置增强 实现
- css样式的优先级
- 顺序栈
- ZOJ 3959 Problem Preparation
- 选择器
- 【笔记】formvalidtor常见问题总结
- 详解c++指针的指针和指针的引用
- R语言-文本挖掘 主题模型 文本分类
- ZOJ 3958 Cooking Competition
- 字体
- 如何在 webpack 中引入未模块化的库,如 Zepto
- 题目1368:二叉树中和为某一值的路径