题意:给你n张卡片,上面写有数字,两个人选择两个数字,把相同数字的卡片都拿走,问能不能拿走所有的卡片并且两个人拿的卡片书相同。

Examples
Input
4
11
27
27
11
Output
YES
11 27
Input
2
6
6
Output
NO
Input
6
10
20
30
20
10
20
Output
NO
Input
6
1
1
2
2
3
3
Output
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的更多相关文章

  1. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

  2. Codeforces Round #436 (Div. 2) A,B,D

    A. Fair Game 题目链接:http://codeforces.com/contest/864/problem/A 水题 #include<iostream> #include&l ...

  3. 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 ...

  4. Codeforces Round #436 (Div. 2) E. Fire

    http://codeforces.com/contest/864/problem/E 题意: 有一堆物品,每个物品有3个属性,需要的时间,失效的时间(一开始)和价值.只能一件一件的选择物品(即在选择 ...

  5. Codeforces Round #436 (Div. 2)

    http://codeforces.com/contest/864 第一次打cf的月赛-- A 题意:给你一个数列,问你能不能保证里面只有两种数且个数相等.2<=n<=100,1<= ...

  6. Codeforces Round #436 (Div. 2) D. Make a Permutation!

    http://codeforces.com/contest/864/problem/D 题意: 给出n和n个数(ai <= n),要求改变其中某些数,使得这n个数为1到n的一个排列,首先保证修改 ...

  7. Codeforces Round #436 (Div. 2) B. Polycarp and Letters

    http://codeforces.com/contest/864/problem/B 题意: 给出一个字符串,要求找到一个集合S,使得从S中选出的所有数,在这些数的位置上的字母全部为小写且是不同的字 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 安装jdk1.8

    这是很普通的shell的脚本,只需要注意:echo 语句内出现的变量,需要转义! #!/bin/bash function get_current_time_stamp(){ echo `date & ...

  2. Python全栈之路----函数----匿名函数

    用lambda声明匿名函数,对lambda定义名字,才能被调用.下面的calc和func功能一致. def calc(x,y): return x*y func = lambda x,y: x*y # ...

  3. 测试那些事儿—postman入门介绍

    1.postman入门介绍 一款功能强大的网页调试与发送网页HTTP请求的工具. 1)模拟各种HTTP请求,如get,post,put,delete 2)测试集合Collection    Colle ...

  4. SQLI DUMB SERIES-9&&10

    第五关.第八关以及第九关.第十关都是使用盲注,除了第五关说的双注入外,也可使用时间注入法 (1)无论输入啥,都回显相同 (2) ?id=1' and sleep(3) --+ 发现有明显延迟,说明可以 ...

  5. k8s中yaml文件pod的语法(转)

    kubernetes yaml格式的Pod配置文件 # yaml格式的pod定义文件完整内容: apiVersion: v1 #必选,版本号,例如v1 kind: Pod #必选,Pod metada ...

  6. 让docker容器开机启动

    网上有些文章说,要让docker 的容器自动在开机启动,是写脚本,比如在 rc.local 中写.其实完全没必要这么麻烦,docker 有相关指令,docker run 指令中加入 --restart ...

  7. BIO、NIO实战

    BIO BIO:blocking IO,分别写一个服务端和客户端交互的C/S实例.服务器端: import java.io.BufferedReader; import java.io.IOExcep ...

  8. java 代码实现使用Druid 链接池获取数据库链接

    因为原先使用的c3p0链接池,时常出现:APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks,以及出 ...

  9. 创建用户自定义函数 SQL

    //创建用户自定义函数------标量函数 create function dbo.bmrs(@bmh as int) returns int as begin declare @bmrs int s ...

  10. Azure CosmosDB (1) 概述

    <Windows Azure Platform 系列文章目录> Azure CosmosDB是一个全球分布式数据库服务(Global Distributed Database),提供低延迟 ...