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;
}
全部评论

相关推荐

hso_:哈哈哈哈哈哈我没offer一样在同一道题开喷了
投递深圳同为数码等公司10个岗位
点赞 评论 收藏
分享
10-05 23:02
东北大学 Java
我说句实话啊:那时候看三个月培训班视频,随便做个项目背点八股,都能说3 40w是侮辱价
点赞 评论 收藏
分享
评论
点赞
收藏
分享
正在热议
# 25届秋招总结 #
443331次浏览 4520人参与
# 春招别灰心,我们一人来一句鼓励 #
42187次浏览 537人参与
# 北方华创开奖 #
107473次浏览 600人参与
# 地方国企笔面经互助 #
7973次浏览 18人参与
# 同bg的你秋招战况如何? #
77166次浏览 569人参与
# 实习必须要去大厂吗? #
55811次浏览 961人参与
# 阿里云管培生offer #
120450次浏览 2220人参与
# 虾皮求职进展汇总 #
116310次浏览 887人参与
# 如果你有一天可以担任公司的CEO,你会做哪三件事? #
11683次浏览 289人参与
# 实习,投递多份简历没人回复怎么办 #
2454962次浏览 34861人参与
# 提前批简历挂麻了怎么办 #
149927次浏览 1978人参与
# 在找工作求抱抱 #
906124次浏览 9423人参与
# 如果公司给你放一天假,你会怎么度过? #
4762次浏览 55人参与
# 你投递的公司有几家约面了? #
33209次浏览 188人参与
# 投递实习岗位前的准备 #
1196037次浏览 18550人参与
# 机械人春招想让哪家公司来捞你? #
157648次浏览 2267人参与
# 双非本科求职如何逆袭 #
662384次浏览 7397人参与
# 发工资后,你做的第一件事是什么 #
12806次浏览 62人参与
# 工作中,努力重要还是选择重要? #
35906次浏览 384人参与
# 简历中的项目经历要怎么写? #
86937次浏览 1516人参与
# 参加完秋招的机械人,还参加春招吗? #
20153次浏览 240人参与
# 我的上岸简历长这样 #
452074次浏览 8089人参与
牛客网
牛客企业服务