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 ...
随机推荐
- ApacheServer-----关于443端口被占用的解决方法
最经公司项目需要经过Apache服务器转发,自己也下载了ApacheServer,但是在启动的过程中,遇到443端口被占用,网上看了一些解决方法,都不对,没有解决问题. 执行启动命令httpd -k ...
- 【转】CSS3动画帧数科学计算法
本文来源于:财付通TID 原作者:bboy90 总结都浓缩在这个工具里了,想知道工具的地址或想窥探工具诞生的趣事请往下看 . —————————————————————– 华丽丽的开篇 ...
- jelq
初级 The Newbie Routine 5 minutes hot wrap 5 minutes manual stretch (ten 30-second stretches) 10 minut ...
- sqlserver中将某数据库下的所有表字段名称为小写的改为大写
declare @name varchar(50), @newname varchar(50),@colname varchar(50) declare abc cursor for select ( ...
- nyoj 10 skiing 搜索+动归
整整两天了,都打不开网页,是不是我提交的次数太多了? nyoj 10: #include<stdio.h> #include<string.h> ][],b[][]; int ...
- POJ 1061 青蛙的约会
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 82859 A ...
- nginx的那些内置变量
nginx在配置文件nginx.conf中可以使用很多内置变量,配置如下: location /info { add_header 'Content-Type' 'text/html'; echo & ...
- div动态显示iframe内容
在div里隐藏不了iframe <div id="popupmenu" style="position:relative; display:none; z-inde ...
- Android文本读写
//写文件操作 public void writeFileData(String fileName, String message){ try{ FileOut ...
- iOS开发——UI基础-按钮内边距,图片拉伸
一.内边距 UIButton有三个属性,分别可以设置按钮以及内部子控件的内边距 1.contentEdgeInsets 如果是设置contentEdgeInsets, 会把UIImageView和UI ...