Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
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.
Input
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.
OutputPrint "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 250 85 25010 15 25
Limak
3 650 85 25010 15 25
Radewoosh
8 110 20 30 40 50 60 70 808 10 58 63 71 72 75 76
Tie
<span style="font-family:SimSun;font-size:18px;">#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[60],b[60],c[60],d[60];
int main()
{
int n,s;
while(scanf("%d%d",&n,&s)!=EOF)
{
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
c[n-1-i]=a[i];
}
for(int i=0;i<n;i++)
{
scanf("%d",&b[i]);
d[n-1-i]=b[i];
}
int s1=0,s2=0;
for(int i=1;i<n;i++)
{
b[i]+=b[i-1];
d[i]+=d[i-1];
}
for(int i=0;i<n;i++)
{
s1+=max(0,a[i]-s*b[i]);
s2+=max(0,c[i]-s*d[i]);
}
if(s1>s2)
printf("Limak\n");
else if(s2>s1)
printf("Radewoosh\n");
else
printf("Tie\n");
}
return 0;
}
</span>