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 ...
随机推荐
- 前台js分页,自己手写逻辑2
//设置分页 var pageSize = 10; //设置一次显示多少页 var pageLimit = 5; $(function(){ $.post("rest/rtdbfix/lis ...
- windows服务
.net windows 服务创建.安装.卸载和调试 原文:http://www.cnblogs.com/hfliyi/archive/2012/08/12/2635290.html 我对例子做了 ...
- C# 对象操作
//********************************************************************************* //************** ...
- apache vhost
httpd.conf: Include "F:/wamp/alias/*" <Directory "F:\wamp\www"> Options ...
- October 3rd 2016 Week 41st Monday
Better to light one candle than to curse the darkness. 与其诅咒黑暗,不如燃起蜡烛. Sitting in the darkness and wa ...
- 让chrome的控制台更高大上(装B用)
作为一名屌丝前端程序员,在装B的道路上是越走越远了!废话不多说,直接先上几张图:我的Element是这样的: 我的console是这个样子的: 我的Timeline是这个样子的: ---------- ...
- javascript void运算符
参考链接:http://www.cnblogs.com/ziyunfei/archive/2012/09/23/2698607.html语法: void expr 作用:计算表达式expr,并返回un ...
- vs win32 & MFC 指针默认位置
一开始win32指针所在的位置是与debug文件夹同级的.即打开打开改程序的第一个文件夹这一级. MFC指针是在第二个debug下头,就是打开第二个project名词的文件夹下头,e.g., &quo ...
- android 开发赚钱
原 android 开发赚钱 谁带我去看看世界 发布时间: 2015/06/09 12:05 阅读: 1589 收藏: 37 点赞: 2 评论: 5 开发android也有一年左右了,利用业余时间陆续 ...
- mysql里表以及列的增删改查
在一个表里插入数据(增) insert into 表名 (需要插入的列名如 id,name,age)values (1,'张三',20), (2,'李四',30): 查询表内容(查 ...