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 ...
随机推荐
- 《Effective C++》第三版笔记
阅读此笔记前,请先阅读 <Effective C++>第二版笔记 和 <More Effective C++>笔记 这里只记录与上面笔记不同的条款,主要是 "面对 ...
- autopep8
修正python pep8的警告挺无趣的, 用了 autopep8 感觉比较爽. 记录如下. ----------------pep8检查----------------平时我用pydev做pep8检 ...
- [设计模式] javascript 之 享元模式;
享元模式说明 定义:用于解决一个系统大量细粒度对象的共享问题: 关健词:分离跟共享: 说明: 享元模式分单纯(共享)享元模式,以及组合(不共享)享元模式,有共享跟不共享之分:单纯享元模式,只包含共享的 ...
- Linux(Red Hat)-中安装Vmware Tools
0. 会弹出 ***1.在弹出的文件夹中找到"VMwwareTools9.6.2-1688356.tar.gz",右击"解压缩到"...我解压缩到了" ...
- 繁华模拟赛day8 牛栏
/* 标称并没有用到题解中提到的那种奇妙的性质,我们可以证明,正常从1开始走的话,需要T次,如何使这个次数减小?题解中提到一个办法,有一步小于n/t,我们考虑这一步,如果把它匀到左右两步中,则可以减小 ...
- 微信电脑版微信1.1 for Windows更新 可@人/转发撤回消息/可播小视频
微信电脑版微信1.1 for Windows发布更新了,版本号为1.1.0.18,群聊可@人/可转发撤回消息/可播小视频,功能越来越接近微信手机版了. 本次更新的一些新特点: 群聊中可以@人. 消息可 ...
- Opencv CamShift+Kalman目标跟踪
#include "stdio.h" #include "string.h" #include "iostream" #include &q ...
- 2016年10月12日--string、Math类、Random随机数、DateTime、异常保护
string string.length; //得到string长度 string.Trim(); //去掉string前后的空格 string.TrimStart(); //去掉string前的空格 ...
- MS DOS 命令大全
刚好看到留下来以备用: 一)MD——建立子目录命令 1.功能:创建新的子目录 2.类型:内部命令 3.格式:MD[盘符:][路径名]〈子目录名〉 4.使用说明: (1)“盘符”:指定要建立子目录的磁盘 ...
- 2.实现Express中间件
Express提供的大部分功能都是通过中间件函数完成,这些中间件函数在Node.js收到 请求的时点 和 发送响应的时点 执行 connect模块提供了中间件框剪 方便在全局或路径级别或为单个路由插入 ...