cf493B Vasya and Wrestling
Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins.
When the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wins.
If the sequences of the awarded points coincide, the wrestler who performed the last technique wins. Your task is to determine which wrestler won.
The first line contains number n — the number of techniques that the wrestlers have used (1 ≤ n ≤ 2·105).
The following n lines contain integer numbers ai (|ai| ≤ 109, ai ≠ 0). If ai is positive, that means that the first wrestler performed the technique that was awarded with ai points. And if ai is negative, that means that the second wrestler performed the technique that was awarded with ( - ai) points.
The techniques are given in chronological order.
If the first wrestler wins, print string "first", otherwise print "second"
5
1
2
-3
-4
3
second
3
-1
-2
3
first
2
4
-4
second
Sequence x = x1x2... x|x| is lexicographically larger than sequence y = y1y2... y|y|, if either |x| > |y| and x1 = y1, x2 = y2, ... , x|y| = y|y|, or there is such number r (r < |x|, r < |y|), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 > yr + 1.
We use notation |a| to denote length of sequence a.
模拟
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
ll i,j,t,n,m,l,r,k,z,y,x;
ll a[200005],b[200005];
ll suma,sumb;
int main()
{
scanf("%I64d",&n);
a[0]=b[0]=0;
suma=sumb=0;
for (i=1;i<=n;i++)
{
scanf("%I64d",&x);
if (x>0)
{
a[++a[0]]=x;
suma+=x;
}
if (x<0)
{
b[++b[0]]=-x;
sumb+=-x;
}
t=x;
}
if (suma>sumb) printf("first\n");
else if (suma<sumb) printf("second\n");
else
{
for (i=1;i<=max(a[0],b[0]);i++) if (a[i]!=b[i]) break;
if (a[i]>b[i]) printf("first\n");
else if (a[i]<b[i]) printf("second\n");
else
{
if (t>0) printf("first\n");
else printf("second\n");
}
}
return 0;
}
cf493B Vasya and Wrestling的更多相关文章
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...
- CodeForces 493B Vasya and Wrestling 【模拟】
B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- codeforces 493B.Vasya and Wrestling 解题报告
题目链接:http://codeforces.com/problemset/problem/493/B 题目意思:给出 n 个 techniques,每个 technique 的值为 ai. ai & ...
- Codeforces Round #281 (Div. 2)
题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football gam ...
- codeforces493B
Vasya and Wrestling CodeForces - 493B Vasya has become interested in wrestling. In wrestling wrestle ...
- Codeforces Round #281 (Div. 2) B 模拟
B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Milliard Vasya's Function-Ural1353动态规划
Time limit: 1.0 second Memory limit: 64 MB Vasya is the beginning mathematician. He decided to make ...
- CF460 A. Vasya and Socks
A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 递推DP URAL 1353 Milliard Vasya's Function
题目传送门 /* 题意:1~1e9的数字里,各个位数数字相加和为s的个数 递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数 状态转移方程:dp[i][j] += dp[i-1][j-k] ...
随机推荐
- MySQL日期函数
1.已知出生日期,求年龄 SELECT '1992-04-10' as birthday, curdate(), ( YEAR (curdate()) - YEAR ('1992-04-10')-1 ...
- 知方可补不足~用xsl来修饰xml
概念相关 XSL是可扩展样式表语言的外语缩写,是一种用于以可读格式呈现 XML(标准通用标记语言的子集)数据的语言. 起始于 XSL 万维网联盟(W3C)开始发展 XSL 的原因是:存在着对于基于 X ...
- Gulp:静态资源(css,js)版本控制
为了防止客户端的静态资源缓存,我们需要每次更新css或js的时候,通过md5或时间戳等方式重新命名静态资源: 然后涉及到的html模板里的src也要做相应的修改,静态资源需要优化(压缩合并) 文件目录 ...
- 正则表达式:网页爬虫:从TXT中获取邮箱地址(获取的练习,缺点:一行只能匹配一个)
import java.util.regex.*; import java.io.*; class L { public static void main(String[] args) throws ...
- Vss服务端用户存在,但客户端登陆不进去
打开客户端Vss提示“Cannot find SS.INI file for user userName”,这个错误是找不到用户userName的SS.INI文件. 解决办法 在服务器上找到Vss共享 ...
- apache ab工具对网站进行压力测试
Apache -- ab工具主要测试网站的(并发性能) 这个工具非常的强大. 基本语法 : cmd>ab.exe –n 请求总次数 -c 并发数 请求页面的url 进入到ab.ex ...
- Sql省市三级联动一张表
CREATE TABLE [dbo].[region]( [region_id] [int] NULL, [region_name] [varchar](50) COLLATE Chinese_PRC ...
- java文件io过滤器
package cn.stat.p1.file; import java.io.File; public class newfilelist { /** * @param args */ public ...
- [Android分享] 如何解决Android 5.0中出现的警告:Service Intent must be explicit
Android 5.0程序运行报Service Intent must be explicit错误,原因是5.0的service必须显式调用 改成 Intent intent = new Intent ...
- android环境搭配 运行android sdk manager时出现错误问题解决
本来前几天已经搭配好android环境开发(eclipse+android sdk+jdk),也已经运行成功了.但是最近因为出现了一些问题,所以把前面搭配好的环境都卸载了.重新搭配的时候发现在运行 s ...