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 ...
随机推荐
- php之thinkphp部署Linux
今天在学习thinkphp时遇到很多的问题,为了能够更好的学习今天抽出下午时间,对lamp环境下的开发进行了一些尝试,毕竟以前做过很多与Linux相关的工作,再加上php本身最优的搭配就是lamp环境 ...
- Html书写规范
#cnblogs_post_body ol { padding-left: 0px; } body { line-height: 1.6; } body, th, td, button, input, ...
- Jcrop+uploadify+php实现上传头像预览裁剪
最近由于项目需要,所以做了一个上传头像预览并且可以预览裁剪的功能,大概思路是上传的图片先保存到服务器,然后通过ajax从服务器获取到图片信息,再利用Jcrop插件进行裁剪,之后通过PHP获取到的四个裁 ...
- HNU 12885 Bad Signal(模拟)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12885&courseid=274 解题报告:一共有n个 ...
- 使用 Github Pages 发布你的项目文档
导读 你可能比较熟悉如何用 Github Pages 来分享你的工作,又或许你看过一堂教你建立你的第一个 Github Pages 网站的教程.近期 Github Pages 的改进使得从不同的数据源 ...
- word20161130
1. even 偶数 [ǒu shù][词典] even; [数] even number;[例句]在本例中,slot A中有奇数个阵列,slot B中有偶数个阵列.In this example, ...
- HTTP请求常见状态码
HTTP状态码(HTTP Status Code) 一些常见的状态码为: 1xx(临时响应)表示临时响应并需要请求者继续执行操作的状态代码.代码 说明 100 (继续) 请求者应当继续提出请求. 服务 ...
- Android中的四种动画(一)
TweenAnimation 变换动画(也叫作"补间动画"),有四种(alpha scale translate rote). FrameAnimation(也叫DrawableA ...
- ejs模板
nodejs的模板引擎有很多, ejs是比较简单和容易上手的.常用的一些语法: 用<%...%>包含js代码 用<%=...%>输出变量 变量若包含 '<' '>' ...
- weiphp执行的流程
微信交互 1.用户与微信进行交互,交互的事件包括:回复公众号,扫描与公众号有关的二微码,关注(取消关注)公众号,在公众号里点击自定义菜单等 2.微信把用户的交互事件及相关参数传递给weiphp的微 ...