【codeforces】 Bear and Reverse Radewoosh

系统管理员 2022-07-16 23:41 287阅读 0赞

A. Bear and Reverse Radewoosh

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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 p**i and it takes exactly t**i minutes to solve it. Problems are sorted by difficulty — it’s guaranteed that p**i < p**i + 1 and t**i < t**i + 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,  p**i - c·x) points.

Limak is going to solve problems in order 1, 2, …, n (sorted increasingly by p**i). Radewoosh is going to solve them in order n, n - 1, …, 1(sorted decreasingly by p**i). 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 t**i. 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, …, p**n (1 ≤ p**i ≤ 1000, p**i < p**i + 1) — initial scores.

The third line contains n integers t1, t2, …, t**n (1 ≤ t**i ≤ 1000, t**i < t**i + 1) where t**i denotes the number of minutes one needs to solve the i-th problem.

Output

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.

Examples

input

  1. 3 2
  2. 50 85 250
  3. 10 15 25

output

  1. Limak

input

  1. 3 6
  2. 50 85 250
  3. 10 15 25

output

  1. Radewoosh

input

  1. 8 1
  2. 10 20 30 40 50 60 70 80
  3. 8 10 58 63 71 72 75 76

output

  1. Tie

Note

In the first sample, there are 3 problems. Limak solves them as follows:

  1. Limak spends 10 minutes on the 1-st problem and he gets 50 - c·10 = 50 - 2·10 = 30 points.
  2. Limak spends 15 minutes on the 2-nd problem so he submits it 10 + 15 = 25 minutes after the start of the contest. For the 2-nd problem he gets 85 - 2·25 = 35 points.
  3. He spends 25 minutes on the 3-rd problem so he submits it 10 + 15 + 25 = 50 minutes after the start. For this problem he gets250 - 2·50 = 150 points.

So, Limak got 30 + 35 + 150 = 215 points.

Radewoosh solves problem in the reversed order:

  1. Radewoosh solves 3-rd problem after 25 minutes so he gets 250 - 2·25 = 200 points.
  2. He spends 15 minutes on the 2-nd problem so he submits it 25 + 15 = 40 minutes after the start. He gets 85 - 2·40 = 5 points for this problem.
  3. He spends 10 minutes on the 1-st problem so he submits it 25 + 15 + 10 = 50 minutes after the start. He getsmax(0, 50 - 2·50) = max(0,  - 50) = 0 points.

Radewoosh got 200 + 5 + 0 = 205 points in total. Limak has 215 points so Limak wins.

In the second sample, Limak will get 0 points for each problem and Radewoosh will first solve the hardest problem and he will get250 - 6·25 = 100 points for that. Radewoosh will get 0 points for other two problems but he is the winner anyway.

In the third sample, Limak will get 2 points for the 1-st problem and 2 points for the 2-nd problem. Radewoosh will get 4 points for the 8-th problem. They won’t get points for other problems and thus there is a tie because 2 + 2 = 4.

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<cstring>
  4. #include<algorithm>
  5. using namespace std;
  6. const int N =55;
  7. int p[N],t[N];
  8. int main() {
  9. int n,c;
  10. while(scanf("%d%d",&n,&c)!=EOF) {
  11. for(int i=0; i<n; i++) {
  12. scanf("%d",&p[i]);
  13. }
  14. for(int i=0; i<n; i++) {
  15. scanf("%d",&t[i]);
  16. }
  17. int scor1=0,scor2=0;
  18. int cnt1=0,cnt2=0;
  19. for(int i=0; i<n; i++) {
  20. cnt1+=t[i];
  21. scor1+=max(0,p[i]-c*cnt1);
  22. }
  23. for(int i=n-1; i>=0; i--) {
  24. cnt2+=t[i];
  25. scor2+=max(0,p[i]-c*cnt2);
  26. }
  27. if(scor1==scor2)
  28. printf("Tie\n");
  29. else if(scor1>scor2)
  30. printf("Limak\n");
  31. else
  32. printf("Radewoosh\n");
  33. }
  34. return 0;
  35. }

题目地址:http://codeforces.com/problemset/problem/658/A

发表评论

表情:
评论列表 (有 0 条评论,287人围观)

还没有评论,来说两句吧...

相关阅读