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 ...
随机推荐
- selenium-java,selenium版本和火狐浏览器版本对应关系
selenium3.5.0,firefox57,geckodriver-v0.19.1
- SQL 优化经历
一次非常有趣的 SQL 优化经历 阅读本文大概需要 6 分钟. 前言 在网上刷到一篇数据库优化的文章,自己也来研究一波. 场景 数据库版本:5.7.25 ,运行在虚拟机中. 课程表 #课程表 cr ...
- python 使用gevent模块实现手动挡切换多协程。
from greenlet import greenlet def test1(): print(12) g2.switch()#切换到协程g2执行,保存执行状态 print(23) g2.switc ...
- Go Example--排序
package main import ( "fmt" "sort" ) func main() { strs := []string{"c" ...
- POJ1738 An old Stone Game
题意 Language:Default An old Stone Game Time Limit: 5000MS Memory Limit: 30000K Total Submissions: 439 ...
- 打印 laravel 模型查询产品的 SQL
1.在路由閉包打印sql 打印一段代码生产的 sql 语句,使用路由闭包做个实验 Route::get('/get-sql', function() { DB::enableQueryLog(); $ ...
- ubuntu12.04 64bit libncurses5-dev和libncurses5-dev:i386共存性问题讨论
ubuntu12.04 64bit 编译kernel(或者make menuconfig)源码时出现如下错误: HOSTLD scripts/kconfig/mconf scripts/kconfig ...
- Node.js express获取参数有三种方法
express获取参数有三种方法:官网介绍如下 Checks route params (req.params), ex: /user/:id Checks query string params ( ...
- leetcode习题练习
day001 #!user/bin/env python # -*- coding:utf-8 -*- #day001 两数之和 #方法1 def Sum(nbs,tgt): len_nums = l ...
- Oracle 关于concat与双竖线用法的补充
--只能连接2个字符串select concat('nod',' chen is ') from dual; --连接2个列名select concat(name,ip2) from vm_info; ...