zoukankan      html  css  js  c++  java
  • 750A New Year and Hurry

    A. New Year and Hurry
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard 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 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.

     1 #include <iostream>
     2 
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     int num, party;
     8     cin >> num >> party;
     9     const int time = 240;
    10     party = time - party;
    11     int ans = 0, n = 1;
    12     while(party > 0 && ans < num)
    13     {
    14         party -= 5*n;
    15         if(party >= 0)
    16         {
    17             n++;
    18             ans ++;
    19         }
    20     }
    21     cout << ans << endl;
    22     return 0;
    23 }
  • 相关阅读:
    4.C#的选择语句练习
    3.C#中的选择语句
    java包静态导入,继承
    新的学期要继续学习喽
    桌球小游戏
    JAVA和C语言的区别
    BIV+CSS网页的标准化布局
    层叠样式表
    学PHP也要懂得HTML
    web开发入门
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6549017.html
Copyright © 2011-2022 走看看