题意:给你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. linux基础命令一

    linux基础命令一 1.date命令 date命令介绍:显示或者设置系统日期 date命令的语法: 显示日期:date  [options...]  [+FORMAT] FORMAT:为显示日期的格 ...

  2. DataTable与DataSet之间的转换Class

    using System;using System.Collections.Generic;using System.Data;using System.Linq; namespace Convert ...

  3. Excel转datatable

    如果想支持 .xls,.xlsx 两种格式 则必须安装一个exe文件,下载路径https://www.microsoft.com/zh-CN/download/details.aspx?id=1325 ...

  4. 第一个Python小项目:图片转换成字符图片

    实现的效果:                                                                                               ...

  5. Eclipse Build path

    Build Path用于设置Java的构建路径,管理Java工程所包含的资源,使工程结构清晰合理. 包括以下几项: Source Source包括 source folder和output folde ...

  6. SVN 撤回已提交的代码

    1. TortoiseSVN -----> Show log 2.右键点击你想撤回的提交 -> Revert changes from this revision ----->Rev ...

  7. redis 4.x 安装哨兵模式 sentinel

    1.下载 http://download.redis.io/releases/redis-4.0.11.tar.gz 2.解压 tar zxvf redis-4.0.11.tar.gz 3.安装 cd ...

  8. Linux中安装python3.6和第三方库

    Linux中安装python3.6和第三方库 如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境,比如yum!!!!! ...

  9. PHP-ML机器学习库之安装篇

    1.PHP-ML库安装要求:PHP>=7.1 2.切换到项目的跟目录下,使用composer进行安装:composer require php-ai/php-ml 安装完成后的目录如下: 新建测 ...

  10. Excel技巧--巧用分列功能整理日期格式

    遇到这样混乱的日期列表,可以使用“分列”功能来整理: 1.选择该列,点击“数据”-->“分列”功能: 2.在对话框中的第1.2步都不用设置,到第3步选择“日期”格式: 4.完成后,再使用单元格格 ...