VK Cup 2016 - Round 1 (Div. 2 Edition) A Bear and Reverse Radewoosh
2016-04-17 00:16
357 查看
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 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
Input
Output
Input
Output
Input
Output
Note
In the first sample, there are 3 problems. Limak solves them as follows:
Limak spends 10 minutes on the 1-st problem and he gets 50 - c·10 = 50 - 2·10 = 30 points.
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.
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 gets 250 - 2·50 = 150 points.
So, Limak got 30 + 35 + 150 = 215 points.
Radewoosh solves problem in the reversed order:
Radewoosh solves 3-rd problem after 25 minutes so he gets 250 - 2·25 = 200 points.
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.
He spends 10 minutes on the 1-st problem so he submits it 25 + 15 + 10 = 50 minutes after the start. He gets max(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 get 250 - 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.
无脑水题 一会cf 一水
题意:第一行 为初始值 第二行为所花时间 c为每个单位时间的花费 升序与降序下 求权值和 按要求不同输出
题解:不用看 水题
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 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
Input
3 2 50 85 250 10 15 25
Output
Limak
Input
3 6 50 85 250 10 15 25
Output
Radewoosh
Input
8 1 10 20 30 40 50 60 70 80 8 10 58 63 71 72 75 76
Output
Tie
Note
In the first sample, there are 3 problems. Limak solves them as follows:
Limak spends 10 minutes on the 1-st problem and he gets 50 - c·10 = 50 - 2·10 = 30 points.
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.
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 gets 250 - 2·50 = 150 points.
So, Limak got 30 + 35 + 150 = 215 points.
Radewoosh solves problem in the reversed order:
Radewoosh solves 3-rd problem after 25 minutes so he gets 250 - 2·25 = 200 points.
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.
He spends 10 minutes on the 1-st problem so he submits it 25 + 15 + 10 = 50 minutes after the start. He gets max(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 get 250 - 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.
无脑水题 一会cf 一水
题意:第一行 为初始值 第二行为所花时间 c为每个单位时间的花费 升序与降序下 求权值和 按要求不同输出
题解:不用看 水题
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<queue> #include<stack> #include<map> #define ll __int64 #define pi acos(-1.0) using namespace std; struct node { int init; int p; }N[55],M[55]; int n,c; int ans1,ans2; bool cmp1(struct node aa,struct node bb) { if(aa.p<bb.p) return true; return false; } bool cmp2(struct node aa,struct node bb) { if(aa.p>bb.p) return true; return false; } int main() { scanf("%d %d",&n,&c); ans1=0; ans2=0; for(int i=0;i<n;i++) { scanf("%d",&N[i].init); M[i].init=N[i].init; } for(int i=0;i<n;i++) { scanf("%d",&N[i].p); M[i].p=N[i].p; } sort(N,N+n,cmp1); sort(M,M+n,cmp2); int exm=0; for(int i=0;i<n;i++) { exm+=N[i].p; if(N[i].init-c*exm>0) { ans1+=N[i].init-c*exm; } } exm=0; for(int i=0;i<n;i++) { exm+=M[i].p; if(M[i].init-c*exm>0) { ans2+=(M[i].init-c*exm); } } if(ans1>ans2) cout<<"Limak"<<endl; if(ans1==ans2) cout<<"Tie"<<endl; if(ans1<ans2) cout<<"Radewoosh"<<endl; return 0; }
相关文章推荐
- 阿里上个财年中国
- 专访阿里陶辉:大规模分布式系统、高性能服务器设计经验分享
- hihocoder 数论一·Miller-Rabin质数测试
- 装饰模式
- BC #80 C Sequence(指数矩阵快速幂)
- Matlab Creo 曲线曲面协同设计(持续更新)
- 基于CentOS7开发之路 --- 第五章 :CentOS 7 安装eclipse并添加 Gnome 启动
- Common Lisp编程初步---环境搭建和外部lisp代码运行
- k近邻(kNN)
- String,StringBuffer,StringBuilder之间的区别
- 去沸点路上的留言板之旅
- 关于jdbc的数据库驱动类DriverManager.getConnection()参数
- python学习笔记十三 JS,Dom(进阶篇)
- 20145322《Java程序设计》第2次实验报告
- mysql5.7免安装版报错处理You must reset your password using ALTER USER statement before executing
- Linux~文件/目录操作
- EasyUI体验-分页多选,选项保留,以及历史记录相结合的保留
- C++初始化列表
- Ubuntu校园网不能正常使用ipv6上网
- 20145240《Java程序设计》第七周学习总结