Codeforces Round #436 A. Fair Game
题意:给你n张卡片,上面写有数字,两个人选择两个数字,把相同数字的卡片都拿走,问能不能拿走所有的卡片并且两个人拿的卡片书相同。
4
11
27
27
11
YES
11 27
2
6
6
NO
6
10
20
30
20
10
20
NO
6
1
1
2
2
3
3
NO 思路:水题啊,瞎搞搞记录一下就好了,看题太不仔细了,还以为每个人能拿多张卡片orz。 代码:
#include<iostream>
#include<string.h>
using namespace std;
int vis[110]; int main(){
int n,x,sum1=0,sum2=0,c=1,k1,k2;
bool f=1;
memset(vis,0,sizeof(vis));
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
if(vis[x]==0){
if(c==3){
f=0;
break;
}
else if(c==1)k1=x,vis[x]=c++;
else if(c==2)k2=x,vis[x]=c++;
}
if(vis[x]==1)sum1++;
else sum2++;
}
if(f&&c==3&&sum1==sum2){
cout<<"YES"<<endl;
cout<<k1<<' '<<k2<<endl;
}
else cout<<"NO"<<endl;
return 0;
}
Codeforces Round #436 A. Fair Game的更多相关文章
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #436 (Div. 2) A,B,D
A. Fair Game 题目链接:http://codeforces.com/contest/864/problem/A 水题 #include<iostream> #include&l ...
- Codeforces Round #436 (Div. 2) C. Bus
http://codeforces.com/contest/864/problem/C 题意: 坐标轴上有x = 0和 x = a两点,汽车从0到a之后掉头返回,从a到0之后又掉头驶向a...从0到a ...
- Codeforces Round #436 (Div. 2) E. Fire
http://codeforces.com/contest/864/problem/E 题意: 有一堆物品,每个物品有3个属性,需要的时间,失效的时间(一开始)和价值.只能一件一件的选择物品(即在选择 ...
- Codeforces Round #436 (Div. 2)
http://codeforces.com/contest/864 第一次打cf的月赛-- A 题意:给你一个数列,问你能不能保证里面只有两种数且个数相等.2<=n<=100,1<= ...
- Codeforces Round #436 (Div. 2) D. Make a Permutation!
http://codeforces.com/contest/864/problem/D 题意: 给出n和n个数(ai <= n),要求改变其中某些数,使得这n个数为1到n的一个排列,首先保证修改 ...
- Codeforces Round #436 (Div. 2) B. Polycarp and Letters
http://codeforces.com/contest/864/problem/B 题意: 给出一个字符串,要求找到一个集合S,使得从S中选出的所有数,在这些数的位置上的字母全部为小写且是不同的字 ...
- Codeforces Round #436 (Div. 2)D. Make a Permutation! 模拟
D. Make a Permutation! time limit per test: 2 seconds memory limit per test: 256 megabytes input: st ...
- Codeforces Round #436 (Div. 2)C. Bus 模拟
C. Bus time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input out ...
随机推荐
- day03字符串
字符串 1.方法详细内容 方法 强制转换 ##### 1.大小写转换 Value.upper() / value.lower() new_value=value.upper() print(new_v ...
- CC3000 Arduino 连接Yeelink中文注释 示例
代码如下“ /*************************************************** *这是一个例子的dfrobot维多-无线集成物联网建兴传感器和控制节点 *产品页面 ...
- 基于Spring-Cloud的微服务框架设计
基于Spring-Cloud的微服务框架设计 先进行大的整体的框架整理,然后在针对每一项进行具体的详细介绍
- python中表示False的一些内置对象
By default, an object is considered true unless its class defines either a __bool__() method that re ...
- [随笔][Golang][golang nil 相关]
nil 是不能比较的 不同类型的nil的address是一样的 不同类型的nil是不能比较的 nil 是map, slice, pointer, channel, func, interface的零值 ...
- OkHttp官方中文文档
https://blog.csdn.net/jackingzheng/article/details/51778793 https://www.cnblogs.com/ldq2016/p/879630 ...
- spring找不到bean
有时候明明有bean,spring找不到bean,这时候需要mvn clean下,有时候xml文件不会每次都编译,改了不clean可能不会生效.
- IIS7.5 PHP环境HTTP经常500错误处理方法
IIS使用FastCGI方式配置PHP以后,在编写PHP程序时,经常会出现HTTP 500错误 HTTP 500(Internal Server Error):服务器尝试执行请求时遇到了意外情况.研究 ...
- TCP/IP学习20180629-数据链路层-ARP、IP
1.数据链路层:IP.ARP.RARPARP协议用来找到目标主机的Ethernet网卡Mac地址,IP协议用来承载数据ARP协议找到目标,IP协议传输数据2.IP协议ip协议是TCP/IP协议的核心, ...
- problem: vue之数组元素中的数组类型值数据改变却无法在子组件视图更新问题
问题:给父组件上的一个数组中的某个元素中的数组类型值,添加值后,数据没有在子组件上更新. 对元素添加值之后,vue的数据其实已经更新了并传给了子组件,子组件中没有立即更新. 那么这里有个问题,在子组件 ...