菜鸡我认为的好题
题意:这里有n个数,两两相互减1,执行n次,问有没有可能这n个数全都变为0;
做法:首先和是奇数是不可能的,然后和为偶数的时候:比如数据
2
2 6 那么结果是不可以的,变 -> 0 4;那么说明了 最大值大于sum/2的话,那么把非最大值的数都抵消掉了,然而抵消过后的最大值就没有地抵消了;相反,最大值小于sum/2的话,那么和也是偶数,最大值是会被其他非最大值一直抵消,知道最大值为0;

B. Zero Array
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given an array a1,a2,…,an.

In one operation you can choose two elements ai and aj (i≠j) and decrease each of them by one.

You need to check whether it is possible to make all the elements equal to zero or not.

Input
The first line contains a single integer n (2≤n≤105) — the size of the array.

The second line contains n integers a1,a2,…,an (1≤ai≤109) — the elements of the array.

Output
Print “YES” if it is possible to make all elements zero, otherwise print “NO”.

Examples
inputCopy
4
1 1 2 2
outputCopy
YES
inputCopy
6
1 2 3 4 5 6
outputCopy
NO
Note
In the first example, you can make all elements equal to zero in 3 operations:

Decrease a1 and a2,
Decrease a3 and a4,
Decrease a3 and a4
In the second example, one can show that it is impossible to make all elements equal to zero.

AC_Code

#include <bits/stdc++.h>
using namespace std;int a[100000+10];
int n;
int main(){ios::sync_with_stdio(false);while(cin >> n){long long sum = 0;for(int i = 0;i< n;i++){cin >> a[i];sum += a[i];}if(sum & 1){cout << "NO" << endl;continue; }sort(a,a+n);          //两两相互减 if(a[n-1] > sum/2){    //最大值比 sum/2 大,说明最大值是自己与自己相互抵消的 cout << "NO" << endl;}else{cout << "YES" << endl;}}
}

Codeforces Round #577 (Div. 2)--B. Zero Array相关推荐

  1. Codeforces Round #727 (Div. 2) F. Strange Array 线段树 + 区间合并 + 排序优化

    传送门 文章目录 题意: 思路: 题意: 给你一个长度为nnn的数组,对每个位置iii求一个最大价值,价值计算方式如下:选择一个包含iii的[l,r][l,r][l,r],让后将其拿出来排序,之后价值 ...

  2. Codeforces Round #702 (Div. 3)——A. Dense Array

    A. Dense Array 题意 T组测试样例,每组n个数据,问最少需要在当前这组数据中插入多少个数使得当前的这组数据满足相邻两个数据之间的最大值与最小值的比值小于等于2. 测试样例解释 input ...

  3. Treasure Hunting Codeforces Round #577 (Div. 2)

    链接: https://codeforces.com/contest/1201/problem/D 题面: You are on the island which can be represented ...

  4. Codeforces Round #700 (Div. 2) D2 Painting the Array II(最通俗易懂的贪心策略讲解)看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 整场比赛的A ~ E 6题全,全部题目超高质量题解链接: Codeforces Round #700 ...

  5. 【Codeforces Round #767 (Div. 2)】 C. Meximum Array 题解

    [Codeforces Round #767 (Div. 2) ]C. Meximum Array 题解 1629C: Meximum Array 题解 [Codeforces Round #767 ...

  6. Codeforces Round #538 (Div. 2) F. Please, another Queries on Array? 线段树 + 欧拉函数

    传送门 文章目录 题意: 思路: 题意: 给你一个序列aaa,你需要实现两种操作: (1)(1)(1) 将[l,r][l,r][l,r]的aia_iai​都乘rrr. (2)(2)(2) 求ϕ(∏i= ...

  7. Codeforces Round #632 (Div. 2) C. Eugene and an array 思维 + 前缀和

    传送门 文章目录 题意: 思路: 题意: 给定一个长度为nnn的序列aaa,定义一段区间为好区间是这段区间的所有连续子区间的和都不为000,求好区间的个数. 思路: 套路题,定义aia_iai​的前缀 ...

  8. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  9. Codeforces Round #698 (Div. 2)(A ~ F)6题全,超高质量题解)【每日亿题】2021/2/4

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 [每日亿题]Codeforces Round #698 (Div. 2)(A ~ F)6题全,超 ...

最新文章

  1. 虚拟机Linux下解决ping时出现 unknown host问题
  2. python 类可以调用实例变量_python中的实例方法、静态方法、类方法、类变量和实例变量浅析...
  3. 杭电Color the ball1556
  4. 基于WASM的无侵入式全链路A/B Test实践
  5. 端口复用和重映射--STM32F103
  6. 【精品计划 附录2】- 算法分析
  7. socket编程五种模型
  8. CES Asia专题|VR、AR硬件一箩筐,迭代升级亮点不多
  9. C++动态绑定和静态绑定
  10. UIFont 设置字体
  11. 2021年JAVA原生安卓影视APP源码支持PC+WAP
  12. 动易 转 html5,动易dedecms数据转成dedecms的php程序
  13. 怎样用matlab拟合,怎么用用matlab拟合两条直线
  14. java 解析dex_将DEX反编译成Java源代码
  15. 【Java】爬虫,看完还爬不下来打我电话
  16. Newtonsoft.Json.Linq 简单使用
  17. python函数调用关系分析
  18. 爬虫-Python编程入门
  19. sar点目标成像matlab,SARrawdata 根据矩阵中的高度数据,通过SAR点目标成像算法 过程,将 转换为实际从飞机 matlab 272万源代码下载- www.pudn.com...
  20. 嵌入式物联网学习方法

热门文章

  1. 赛门铁克:政企云建设与安全要双管齐下
  2. 内网网速取决于网络设备,而外网网速取决于带宽和用户多少
  3. stm32H743基于CubeMX配置为双ADC多通道DMA规则采样
  4. 【王道考研】吸烟者问题
  5. jenkin swindows启动,在Windows上启动/停止并重新启动Jenkins服务
  6. ubuntu下qt模拟键盘按键按下_基于QT的跨平台虚拟键盘设计与实现
  7. linux+nas+私有云软件,自建家庭私有云NAS——磁盘管理系统
  8. 【转】前端——实用UI组件库
  9. 粗放式增长过后,“分层拉活”正兴起
  10. 如何解决Google浏览器被拦截