Codeforces Round #371 (Div. 2) - B
题目链接:http://codeforces.com/contest/714/problem/B
题意:给定一个长度为N的初始序列,然后问是否能找到一个值x,然后使得序列的每个元素+x/-x/不变,最后把序列变成各个元素都相等(序列每个元素只能进行操作一次)
思路:因为每个元素只能操作一次,而且操作的值只有一个值x。那么就可以发现当序列中存在3个以上的互不相等的数时一定不能构造要求的序列。 当序列存在3个一下的互补相同的数时,一定能构造要求的序列。现在要考虑的是刚刚有3个互不相同的序列时,把序列去重+排序后,如果数2-数1=数3-数2.则可以构造,否则不能构造。
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<time.h>
#include<cmath>
#include<set>
using namespace std;
typedef long long int LL;
const int MAX = + ;
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
int n,num;
while (~scanf("%d", &n)){
set<int>se;
for (int i = ; i < n; i++){
scanf("%d", &num); se.insert(num);
}
if (se.size()>){
printf("NO\n");
}
else if (se.size() == ){
vector<int>m;
for (set<int>::iterator it = se.begin(); it != se.end(); it++){
m.push_back(*it);
}
sort(m.begin(), m.end());
if (m[] - m[] == m[] - m[]){
printf("YES\n");
}
else{
printf("NO\n");
}
}
else{
printf("YES\n");
}
}
return ;
}
Codeforces Round #371 (Div. 2) - B的更多相关文章
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #371 (Div. 2)B. Filya and Homework
题目链接:http://codeforces.com/problemset/problem/714/B 题目大意: 第一行输入一个n,第二行输入n个数,求是否能找出一个数x,使得n个数中的部分数加上x ...
- Codeforces Round #371 (Div. 2) - A
题目链接:http://codeforces.com/contest/714/problem/A 题意:有两个人A,B 给定A的时间区间[L1,R1], B的时间区间[L2,R2],然后在正好K分钟的 ...
- 严格递增类的dp Codeforces Round #371 (Div. 1) C dp
http://codeforces.com/contest/713 题目大意:给你一个长度为n的数组,每次有+1和-1操作,在该操作下把该数组变成严格递增所需要的最小修改值是多少 思路:遇到这类题型, ...
- Codeforces Round #371 (Div. 2) C 大模拟
http://codeforces.com/contest/714/problem/C 题目大意:有t个询问,每个询问有三种操作 ①加入一个数值为a[i]的数字 ②消除一个数值为a[i]的数字 ③给一 ...
- Codeforces Round #371 (Div. 1) C. Sonya and Problem Wihtout a Legend 贪心
C. Sonya and Problem Wihtout a Legend 题目连接: http://codeforces.com/contest/713/problem/C Description ...
- Codeforces Round #371 (Div. 1) D. Animals and Puzzle 二维倍增
D. Animals and Puzzle 题目连接: http://codeforces.com/contest/713/problem/D Description Owl Sonya gave a ...
- Codeforces Round #371 (Div. 2) C. Sonya and Queries 水题
C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learn ...
- Codeforces Round #371 (Div. 2) D. Searching Rectangles 交互题 二分
D. Searching Rectangles 题目连接: http://codeforces.com/contest/714/problem/D Description Filya just lea ...
随机推荐
- 屏幕截图、录像FastStone Capture
作为一款极其优秀好用的屏幕截图软件,FastStone Capture 具有体积小巧.功能强大.操作简便等优点,其方便的浮动工具条和便捷的快捷键堪称完美结合,截图后的图片编辑与保存选项也特别丰富和方便 ...
- sql server 取日期
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM Select CONVERT(varchar(100), GETDATE( ...
- [Android进阶]学习AccessibilityService实现微信抢红包插件
在你的手机更多设置或者高级设置中,我们会发现有个无障碍的功能,很多人不知道这个功能具体是干嘛的,其实这个功能是为了增强用户界面以帮助残障人士,或者可能暂时无法与设备充分交互的人们 它的具体实现是通过A ...
- MongoDB C API
一.编译mongodb c driver: 编译完成之后在c:\mongo-c-driver目录下有bin.include.lib三个文件夹,分别包含所需的dll..h文件.lib. 在自己的项目中引 ...
- IDT5V49EE904资料学习
一.特性: 1.4个内部PLL 2.内部非易失EEPROM. 3.最快400k的I2C串行接口. 4.输入时钟范围:1M—200M. 5.输出时钟范围:4.9k—200M 6.输入晶振参数带有在线可编 ...
- iis 7.5应用程序池自动停止
今天在我的windows7旗舰版上配置iis7 (Internet Information Server)失败,一直未能启动服务,访问本地网络提示"Service Unavailable H ...
- wifi 4次握手
转自:http://zhaoxiaobu.blog.51cto.com/878176/407130/ 不管是用WEP加密,还是用WPA,一般如果我们要和AP建立一个连接,要经过两个阶段认证(Authe ...
- .NET生成带Logo的二维码
使用ThoughtWorks.QRCode生成,利用这个库来生成带Logo的二维码(就是中间嵌了一个图片的二维码),直接见代码: HttpContext context = HttpContext.C ...
- [LeetCode] Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- c/s模式 (C#)下Ftp的多文件上传及其上传进度
因为项目要求,制作的一个多文件上传,并显示进度条一段代码(vs2005环境).(只为粗略的实现,代码并不规范) 当多个文件上传的时候,需要依次队列形式一个个上传,当上传某个文件的时候,锁定进程,上传完 ...