【Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined) B】 Conan and Agasa play a Card Game
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
最大值出现次数是偶数。
那么就取次大值。
次大值也是偶数?
=>再次
因为你绝对不能取偶数个的。
取了对方就总是能面对一个奇数的情况了。
则对面总是能拿走最后一个了。
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n,a[N+10];
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++) cin >> a[i];
sort(a+1,a+1+n);
for (int i = n;i>=1;i--){
int j = i;
while (j-1>=1 && a[j-1]==a[i]) j--;
int num = j-i+1;
if (num&1){
return cout<<"Conan"<<endl,0;
}
i = j;
}
cout <<"Agasa"<<endl;
return 0;
}
【Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined) B】 Conan and Agasa play a Card Game的更多相关文章
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] 总共两次询 ...
- Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] 给你 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
随机推荐
- conda常用命令,如何在conda环境中安装gym库?
查看已安装的环境: conda info -e 或 conda env list 创建新环境gymlab: conda create -n gymlab python=3.5 激活环境gymlab: ...
- java RSA加密算法
[转]RSA加密算法 RSA公钥加密算法是1977年由Ron Rivest.Adi Shamirh和LenAdleman在(美国麻省理工学院)开发的.RSA取名来自开发他们三者的名字.RSA是目前 ...
- OpenStack依然大行其道,可是否能等来属于自己的时代
版权声明:不论什么转载需全文转载并保留来源(微信公众号techculture)和该声明,并同一时候转载文后的二维码.否则视作侵权. OpenStack在云计算领域依然火热,甚至能够说势不可挡.这可能是 ...
- 思考一下activity的启动模式
在android里,有4种activity的启动模式.分别为:"standard" (默认) "singleTop" "singleTask" ...
- Android页面事件挂接模拟
Java没有C#的引用类型.因此事件的挂接一般都是利用接口来实现,有两种方式: 1)定义一个实现事件接口的类,然后实现接口方法,然后通过将这个类的实例加入到事件监听器里面: public class ...
- Runtime类中的freeMemory,totalMemory,maxMemory等几个方法
最近在网上看到一些人讨论到Java.lang.Runtime类中的freeMemory(),totalMemory(),maxMemory ()这几个方法的一些题目,很多人感到很迷惑,为什么,在jav ...
- 学习中 常用到的string内置对象方法的总结
//concat() – 将两个或多个字符的文本组合起来,返回一个新的字符串. var str = "Hello"; var out = str.concat(" Wor ...
- Programming Languages - Coursera 整理
找到并学习这门课的原因: 想要学习 functional programming Week1 Introduction and Course-Wide Information week1 很轻松, 主 ...
- POJ - 3842 An Industrial Spy dfs(水)
题意:给你一串数字,最少一个,最多七个,问用这里面的数字能组成多少素数,不重复. 思路:之前还遍历10000000的每一个素数,结果超时,后来发现直接dfs就可以了,只是标记一下做过的数. #prag ...
- sql中的 SET QUOTED_IDENTIFIER OFF、SET ANSI_NULLS ON
代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-- ...