D. Magical Bamboos

题目描述

In a magical forest, there exists N bamboos that don’t quite get cut down the way you would expect.

Originally, the height of the ith bamboo is equal to hi. In one move, you can push down a bamboo and decrease its height by one, but this move magically causes all the other bamboos to increase in height by one.

If you can do as many moves as you like, is it possible to make all the bamboos have the same height?

输入

The first line of input is T – the number of test cases.

The first line of each test case contains an integer N (1 ≤ N ≤ 105) - the number of bamboos.

The second line contains N space-separated integers hi (1 ≤ hi ≤ 105) - the original heights of the bamboos.

输出

For each test case, output on a single line “yes” (without quotes), if you can make all the bamboos have the same height, and “no” otherwise.

样例

inputCopy
2
3
2 4 2
2
1 2
outputCopy
yes
no

题意

简单分析一下我们就会发现明显这个只要所有数的奇偶性质一样就可以了

AC代码

#include <cstdio>
#include <cstring>
#include<algorithm>
using namespace std;
bool cmp(int a,int b){return a>b;
}
const int MAXN =1e5+10;
int arr[MAXN];
int main(){int t;scanf("%d",&t);while (t--){int n;scanf("%d",&n);for(int i=0;i<n;i++) scanf("%d",&arr[i]);sort(arr,arr+n,cmp);int flag=1;for(int i=1;i<n;i++){if((arr[i]-arr[i-1])&1) {flag=0;break;}} if(flag) puts("yes");else puts("no");}return 0;

GYM 101350D. Magical Bamboos相关推荐

  1. Magical Bamboos Gym - 101350D

    Magical Bamboos Gym 题目链接:https://cn.vjudge.net/problem/Gym-101350D In a magical forest, there exists ...

  2. 以太坊区块链积分系统示例讲解

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 查看全文 http://www.taodudu.cc/news/show-4199767.ht ...

  3. SDUT 2021 Spring Individual Contest(for 20) - 1

    文章目录 A - Sherlock Bones B - Unusual Team C - Cheap Kangaroo D - Magical Bamboos E - Competitive Seag ...

  4. 2017 ACM Arabella Collegiate Programming Contest(solved 9/13, complex 12/13)

    A.Sherlock Bones 题意: 给出长度为n的01串,问f(i,j)=f(j,k),(i<j<k)的i,j,k取值种数.其中f(i,j)表示[i,j]内1的个数, 且s[j]必须 ...

  5. 【IOI2020国家集训队作业 Part 1】CF505E Mr. Kitayuta vs. Bamboos

    题目 题目描述 Mr. Kitayuta's garden is planted with nn bamboos. (Bamboos are tall, fast-growing tropical p ...

  6. 强化学习(三) - Gym库介绍和使用,Markov决策程序实例,动态规划决策实例

    强化学习(三) - Gym库介绍和使用,Markov决策程序实例,动态规划决策实例 1. 引言 在这个部分补充之前马尔科夫决策和动态规划部分的代码.在以后的内容我会把相关代码都附到相关内容的后面.本部 ...

  7. Gym - 102082G

    Gym - 102082G https://vjudge.net/problem/2198225/origin 对于数列中任意一个数,要么从最左边到它不递减,要么从最右边到到它不递减,为了满足这个条件 ...

  8. 安装gym库_强化学习Gym库学习实践(一)

    最近看了一篇研究方向相关的文章,介绍了一种DQN的应用,感觉还挺新鲜的.想着把这篇文章复现出来,就开始学习强化学习的相关知识,作为一名小白,这一路走的可是真的十分艰难(我太菜了啊!) 看了莫烦Pyth ...

  9. 强化学习环境库 Gym 发布首个社区发布版,全面兼容 Python 3.9

    作者:肖智清 来源:AI科技大本营 强化学习环境库Gym于2021年8月中旬迎来了首个社区志愿者维护的发布版Gym 0.19.该版本全面兼容Python 3.9,增加了多个新特性. 强化学习环境库的事 ...

最新文章

  1. R语言广义线性模型Logistic回归模型列线图分析(nomogram)
  2. (转载)用oracle触发器对记录表增加记录的问题
  3. 【C语言简单说】六:取模运算符以及变量的扩展
  4. [学习笔记]批次需求计划系统-简要
  5. Javascript 中 JSON 与对象 的相互转换
  6. Teamcenter2007 安装步骤
  7. saiku 展示优化
  8. 织梦轻量级mvc框架笔记
  9. java 二进制置位,重置
  10. 全网首发:以字型为例,一维表示的二维数组矩阵,以易理解的方式旋转90、-90
  11. 2016 1月1日-1月1日python 学习总结
  12. 投区块链?听听当下硅谷最火的四条投资军规
  13. 靠卖艺还债:罗永浩的冬天来了!
  14. (八)Mybatis当中#{}常用属性的用法
  15. 一、 Hbase特性 3v特性,Volume(量级) Varity(种类) Velocity(速度)
  16. 74LVC245电平转换电路
  17. 停止抱怨英语_停止抱怨
  18. java小数的数据类型_【填空题】Java 中小数默认的数据类型为 ,如果要指定为 类型,要在小数后面加F或f。...
  19. 实验吧-who are you?
  20. 服务器迁移需要备份哪些文件?

热门文章

  1. tiktok英国小店注册流程介绍
  2. VB计算汉字笔画数代码
  3. spring boot 中阿里druid 数据源配置及密码加密
  4. NYOJ_613_免费馅饼
  5. M1版MacBookAir使用情况(供购买参考)
  6. ReadLikeHumans: Autonomous,Bidirectional and Iterative Language Modeling for Scene Text Recognition
  7. CUDA——线程束分化
  8. OpenMV新手上路1 -- OpenMV简介、参数描述
  9. Python pass 用法
  10. eclipse中在包内建包