codeforces 658A A. Bear and Reverse Radewoosh(水题)
题目链接:
2 seconds
256 megabytes
standard input
standard output
Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order.
There will be n problems. The i-th problem has initial score pi and it takes exactly ti minutes to solve it. Problems are sorted by difficulty — it's guaranteed that pi < pi + 1 and ti < ti + 1.
A constant c is given too, representing the speed of loosing points. Then, submitting the i-th problem at time x (x minutes after the start of the contest) gives max(0, pi - c·x) points.
Limak is going to solve problems in order 1, 2, ..., n (sorted increasingly by pi). Radewoosh is going to solve them in order n, n - 1, ..., 1(sorted decreasingly by pi). Your task is to predict the outcome — print the name of the winner (person who gets more points at the end) or a word "Tie" in case of a tie.
You may assume that the duration of the competition is greater or equal than the sum of all ti. That means both Limak and Radewoosh will accept all n problems.
The first line contains two integers n and c (1 ≤ n ≤ 50, 1 ≤ c ≤ 1000) — the number of problems and the constant representing the speed of loosing points.
The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 1000, pi < pi + 1) — initial scores.
The third line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 1000, ti < ti + 1) where ti denotes the number of minutes one needs to solve thei-th problem.
Print "Limak" (without quotes) if Limak will get more points in total. Print "Radewoosh" (without quotes) if Radewoosh will get more points in total. Print "Tie" (without quotes) if Limak and Radewoosh will get the same total number of points.
3 2
50 85 250
10 15 25
Limak
3 6
50 85 250
10 15 25
Radewoosh
8 1
10 20 30 40 50 60 70 80
8 10 58 63 71 72 75 76
Tie 题意: 从前到后和从后到前计算,比较大小; AC代码:
/*
2014300227 658A - 13 GNU C++11 Accepted 15 ms 2280 KB
*/ #include <bits/stdc++.h>
using namespace std;
int n,c;
int p[],t[];
int main()
{
scanf("%d%d",&n,&c);
for(int i=;i<=n;i++)
{
scanf("%d",&p[i]);
}
for(int i=;i<=n;i++)
{
scanf("%d",&t[i]);
}
int x=,y=,ti=,te=;
for(int i=;i<=n;i++)
{
ti+=t[i];
x+=max(,p[i]-c*ti);
}
for(int i=n;i>;i--)
{
te+=t[i];
y+=max(,p[i]-c*te);
}
if(x>y)cout<<"Limak"<<"\n";
else if(x<y)cout<<"Radewoosh"<<"\n";
else cout<<"Tie"<<"\n"; return ;
}
codeforces 658A A. Bear and Reverse Radewoosh(水题)的更多相关文章
- VK Cup 2016 - Round 1 (Div. 2 Edition) A. Bear and Reverse Radewoosh 水题
A. Bear and Reverse Radewoosh 题目连接: http://www.codeforces.com/contest/658/problem/A Description Lima ...
- codeforces 680B B. Bear and Finding Criminals(水题)
题目链接: B. Bear and Finding Criminals //#include <bits/stdc++.h> #include <vector> #includ ...
- codeforces 680A A. Bear and Five Cards(水题)
题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <i ...
- codeforces 653A A. Bear and Three Balls(水题)
题目链接: A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- VK Cup 2016 - Round 1 (Div. 2 Edition) A Bear and Reverse Radewoosh
A. Bear and Reverse Radewoosh time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- codeforces Gym 100187L L. Ministry of Truth 水题
L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Educational Codeforces Round 14 A. Fashion in Berland 水题
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
随机推荐
- ES6使用箭头函数注意点
新事物也是有两面性的,箭头函数有他的便捷有他的优点,但是他也有缺点,他的优点是代码简洁,this提前定义,但他的缺点也是这些,比如代码太过简洁,导致不好阅读,this提前定义,导致无法使用JS进行一些 ...
- java ConcurrentHashMap 初识
“ConcurrentHashMap是一个线程安全的哈希表“,但是不允许key和value为空: HashTable和ConcurrentHashMap都是线程安全的,但是HashTable是同步容器 ...
- mybatis数据查询返回值
查询: 返回值是整数. 小于0是查询的数据不存在,大于0是查询的数据已经存在. 修改: 返回值是整数. 大于0是修改的数据成功,否则就是失败. 添加: 和修改同理.
- msgsnd的一个小问题
今天写了一个System V消息队列的小样例.定义了一个例如以下的结构体: #define MSG_SIZE 8192 struct request { long mtype; int client_ ...
- python3.x中xml.etree.ElementTree解析xml举例
1.新建xml import xml.etree.ElementTree as ETa=ET.Element('elem')c=ET.SubElement(a,'child1')c.text=&quo ...
- Java结束线程的三种方法
线程属于一次性消耗品,在执行完run()方法之后线程便会正常结束了,线程结束后便会销毁,不能再次start,只能重新建立新的线程对象,但有时run()方法是永远不会结束的.例如在程序中使用线程进行So ...
- js new一个函数和直接调用函数的差别
用new和调用一个函数的差别:假设函数返回值是一个值类型(Number.String.Boolen)时,new函数将会返回这个函数的实例对象.而假设这个函数的返回值是一个引用类型(Object.Arr ...
- 【Scala】Scala的Predef对象
隐式引用(Implicit Import) Scala会自己主动为每一个程序加上几个隐式引用,就像Java程序会自己主动加上java.lang包一样. Scala中.下面三个包的内容会隐式引用到每一个 ...
- linux 打印系统时间操作
版权为个人所有,如需转载请说明出处.(东北大亨) http://www.cnblogs.com/northeastTycoon/p/5511498.html 1. 打开shell脚本 例子1:输出两天 ...
- poj 2151Check the difficulty of problems<概率DP>
链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~ 求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...