A. Bear and Reverse Radewoosh

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 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
inputCopy
3 2
50 85 250
10 15 25
outputCopy
Limak
inputCopy
3 6
50 85 250
10 15 25
outputCopy
Radewoosh
inputCopy
8 1
10 20 30 40 50 60 70 80
8 10 58 63 71 72 75 76
outputCopy
Tie

#include <iostream>
#include <algorithm>
using namespace std;

int p[1005];
int t[1005];

int main()
{
    int n, c;
    while(cin >> n >> c)
    {
        for(int i = 0; i < n; ++i)
            cin >> p[i];
        for(int i = 0; i < n; ++i)
            cin >> t[i];
        int a = 0;
        int b = 0;
        int atime = 0;
        for(int i = 0; i < n; ++i)
        {
            atime += t[i];
            a += max(0, p[i] - c * atime);
        }
        int btime = 0;
        for(int i = n - 1; i >= 0; --i)
        {
            btime += t[i];
            b += max(0, p[i] - c * btime);
        }
        if(a == b)
            cout << "Tie" << '\n';
        if(a > b)
            cout << "Limak" << '\n';
        if(a < b)
            cout << "Radewoosh" << '\n';
    }
    return 0;
}
全部评论

相关推荐

01-04 07:53
门头沟学院 C++
心愿便利贴:工作了以后回头再看待这个问题,从客观的视角来讲是因为每个人对自己的要求不同,学习好的人对自己的要求很高,所以觉得考不好就天塌了,认为自己学习好并且值得一份好工作的人也是一样,找不到符合自己预期的工作肯定也会觉得是侮辱,牛客上有很多名校大学生,肯定会存在这种好学生心态啊,“做题区”从来都不是贬义词,这是大部分普通人赖以生存的路径,这个有什么好嘲讽的,有“好学生心态”没有错,但是不要给自己太大的压力了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务