codeforces 493B.Vasya and Wrestling 解题报告
题目链接:http://codeforces.com/problemset/problem/493/B
题目意思:给出 n 个 techniques,每个 technique 的值为 ai。 ai > 0 表示把这个分数给第一个wrestler,ai < 0,表示给第二个wrestler。约定 ai != 0。
如果两个人最终的得分不相等,分数多的那个人获胜。
如果两个人最终的得分相等,可以分两种情况讨论:
(1)序列中至少有一位不相等,那么字典序大的那个获胜。例如第一个人:1, 4, 5, 8 ,第二个人: 2, 3, 6, 7,总和都为18。那么第二个人胜。
(2)序列中每位都相等,那么最后得分的那个人获胜。例如给出的 n 个数为 -4, 4,那么第一个人获胜。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std; typedef __int64 LL;
const int maxn = 2e5 + ;
int a[maxn], b[maxn];
LL sum; int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE int n, in;
while (scanf("%d", &n) != EOF)
{
sum = ;
int mark;
int l1 = , l2 = ; for (int i = ; i < n; i++)
{
scanf("%d", &in);
sum += in; if (in > )
{
a[l1++] = in;
mark = ;
}
else
{
b[l2++] = -in;
mark = ;
}
}
// 最终的得分不相等
if (sum > )
printf("first\n");
else if (sum < )
printf("second\n");
// 最终的得分相等
else
{
int flag = ; for (int i = ; i < l1 && i < l2; i++) // 两条得分序列中至少有一位不相等
{
if (a[i] > b[i])
{
flag = ;
break;
}
else if (a[i] < b[i])
{
flag = ;
break;
}
} if (!flag) // 两条得分序列相等时,最后得分的那个人获胜
{
if (l1 == l2)
printf("%s\n", mark == ? "first" : "second");
}
else // 得分序列不相等
printf("%s\n", flag == ? "first" : "second");
}
}
return ;
}
codeforces 493B.Vasya and Wrestling 解题报告的更多相关文章
- CodeForces 493B Vasya and Wrestling 【模拟】
B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- codeforces 460A Vasya and Socks 解题报告
题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...
- codeforces 493A. Vasya and Football 解题报告
题目链接:http://codeforces.com/contest/493/problem/A 题目意思:给出两个字符串,分别代表 home 和 away.然后有 t 个player,每个playe ...
- Codeforces Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- codeforces 476C.Dreamoon and Sums 解题报告
题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- codeforces 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- codeforces B. Xenia and Ringroad 解题报告
题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...
随机推荐
- Python3中urllib详细使用方法(header,代理,超时,认证,异常处理)
urllib是python的一个获取url(Uniform Resource Locators,统一资源定址器)了,我们可以利用它来抓取远程的数据进行保存哦,下面整理了一些关于urllib使用中的一些 ...
- 【Auto Layout】Xcode6及以上版本,创建Auto Layout 约束时产生的一些变化【iOS开发教程】
[#Auto Layout#]Xcode6创建Auto Layout 约束时产生的一些变化 通过两个小Demo来展示下变化: Demo1需求: 为控制器的根视图(图中的“控制器View”)的子 ...
- 自动去除nil的NSDictionary和NSArray构造方法
http://www.jianshu.com/p/a1e8d8d579c7 极分享 http://www.finalshares.com/
- Windows Phone自带的语音识别
WindowsPhone下语音操作包括: 1.程序内部的语音识别,用户可以通过语音识别进行输入或完成相关任务 2.控制程序的语音命令,控制程序启动.打开,并可对页面跳转等进行操作 这篇文章将构建一个简 ...
- 必须知道的.net(字段、属性和方法)
1.字段 通常定义为private(封装原则) 2.属性(property) 通常定义为public,表示类的对外成员.具有可读可写属性,通过get和set访问器实现 3.索引器(indexer) C ...
- Mac Pro 编译安装 PHP扩展 -- Swoole扩展
回顾下先前的安装笔记: PHP5不重新编译,如何安装自带的未安装过的扩展,如soap扩展? #下载 Swoole-1.8.10后,开始编译# cd /Users/jianbao/Downloads/s ...
- time_t 获取的是UCT时间,有时差
int main() { time_t nowTime; time(&nowTime);//获取当前时间(世界时间)//这种写法也一样nowTime=time(NULL) ; //如果要转化为 ...
- PYTHON 自动化之路 (二)
一.python 模块的使用 模块的使用: import os #调用 os 模块 cmd_s = os.popen("dir").read() #打开路径为结果保存为cmd_sp ...
- android中返回键捕获处理
在android平台上捕获Back键事件,主要用来处理返回的相关逻辑,下列几种方法都可以捕获,如下所示: 1.获取按钮按下事件,兼容android 1.0到android 2.1,重写onKeyDow ...
- qt-5.6.0 移植之实现板子与ubuntu主机通过网络进行文件传输
经过一上午的调试以及同事的帮助,终于实现板子与主机的文件传输. 第一步关闭所有的防火墙 在 Windows 里面是在控制面板->安全->Windows 防火墙->自定义设置 在ubu ...