zoukankan      html  css  js  c++  java
  • codeforces 658A A. Bear and Reverse Radewoosh(水题)

    题目链接:

    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 thei-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

    题意:

    从前到后和从后到前计算,比较大小;


    AC代码:

    /*
    2014300227    658A - 13    GNU C++11    Accepted    15 ms    2280 KB
    */
    
    #include <bits/stdc++.h>
    using namespace std;
    int n,c;
    int p[60],t[60];
    int main()
    {
        scanf("%d%d",&n,&c);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&p[i]);
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&t[i]);
        }
        int x=0,y=0,ti=0,te=0;
        for(int i=1;i<=n;i++)
        {
            ti+=t[i];
            x+=max(0,p[i]-c*ti);
        }
        for(int i=n;i>0;i--)
        {
            te+=t[i];
            y+=max(0,p[i]-c*te);
        }
        if(x>y)cout<<"Limak"<<"
    ";
        else if(x<y)cout<<"Radewoosh"<<"
    ";
        else cout<<"Tie"<<"
    ";
    
        return 0;
    }


  • 相关阅读:
    G面经prepare: Maximum Subsequence in Another String's Order
    G面经prepare: Set Intersection && Set Difference
    G面经prepare: Pattern Match
    G面经prepare: Data Stream Average
    Summary: Final Keyword
    G面经prepare: Android Phone Unlock Pattern
    G面经prepare: Jump Game Return to Original Place
    G面经prepare: Reorder String to make duplicates not consecutive
    G面经prepare: Sort String Based On Another
    G面经Prepare: Valid Preorder traversal serialized String
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5332473.html
Copyright © 2011-2022 走看看