codeforces 750A.New Year and Hurry

发布于:2022-08-10 ⋅ 阅读:(295) ⋅ 点赞:(0)

活动地址:CSDN21天学习挑战赛

作者:zhenyi

专栏:codeforces800

A. New Year and Hurry

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.

题意:

         Limak将在2016年的最后一天参加一场比赛。比赛将于20:00开始,将持续四个小时,直到午夜。总共有n个问题,按难度排序,即问题1最容易,问题n最难。Limak知道他将花费5·i分钟来解决第i个问题。

        Limak的朋友们组织了一个新年前夜派对,Limak想在午夜或更早的时候到那里。他需要k分钟从他家到那里,他将在那里参加比赛的第一个。

        如果Limak想要参加派对,他能解决多少问题?

#include <iostream>

using namespace std;

int main()
{
    int num, party;
    cin >> num >> party;
    const int time = 240;
    party = time - party;
    int ans = 0, n = 1;
    while(party > 0 && ans < num)
    {
        party -= 5*n;
        if(party >= 0)
        {
            n++;
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

如果对您有帮助,点个关注吧,持续更新中,谢谢支持。如果有问题或错误,欢迎指出与我联系,谢谢。

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到