• 【codeforces 750A】New Year and Hurry


    time limit per test1 second
    memory limit per test256 megabytes
    inputstandard input
    outputstandard output
    Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.

    Limak’s friends organize a New Year’s Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.

    How many problems can Limak solve if he wants to make it to the party?

    Input
    The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.

    Output
    Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.

    Examples
    input
    3 222
    output
    2
    input
    4 190
    output
    4
    input
    7 1
    output
    7
    Note
    In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenario Limak would solve 2 problems. He doesn’t have enough time to solve 3 problems so the answer is 2.

    In the second sample, Limak can solve all 4 problems in 5 + 10 + 15 + 20 = 50 minutes. At 20:50 he will leave the house and go to the party. He will get there exactly at midnight.

    In the third sample, Limak needs only 1 minute to get to the party. He has enough time to solve all 7 problems.

    【题目链接】:http://codeforces.com/contest/750/problem/A

    【题解】

    总共的时间是240分钟;
    扣掉k;
    看看剩下的时间你能做几道题咯?
    因为i*5是个单调递增的;
    所以每次先选择花费时间少的是不会错的;

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define rei(x) scanf("%d",&x)
    #define rel(x) scanf("%I64d",&x)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    //const int MAXN = x;
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    
    int n,k;
    
    int main()
    {
        //freopen("F:\rush.txt","r",stdin);
        rei(n);rei(k);
        int temp = 240-k;
        int ans = 0;
        rep1(i,1,n)
        {
            int cost = i*5;
            if (temp-cost>=0)
            {
                temp-=cost;
                ans++;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
  • 相关阅读:
    Oracle EBS 配置文件取值
    “嗯...无法访问此页面 尝试此操作.....”的解决方法
    为什么在开发的微信小程序项目里写不上汉字?
    VM1238:2 pages/logs/logs.json 文件解析错误 SyntaxError: Unexpected token / in JSON at position 41....
    allparis工具的使用
    can't open 1.txt at releaseallpairs.pl line 368.
    element.style的样式问题解决方法
    常见的http状态码有哪些,代表什么意思?
    怎样快速修改文件名的后缀
    “该文件没有与之关联的应用来执行操作请安装应用若已安装应用程序请在默认应用设置...”
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626745.html
Copyright © 2020-2023  润新知