A. New Year and Hurry

Codeforces
IDCF750A
Time1000ms
Memory256MB
Difficulty
binary searchbrute forceimplementationmath
English · Original
Chinese · Translation
Formal · Original
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. [samples] ## 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 开始,持续四小时,恰好到午夜结束。共有 #cf_span[n] 道题目,按难度排序,即第 #cf_span[1] 题最简单,第 #cf_span[n] 题最难。Limak 知道他解决第 #cf_span[i] 题需要 #cf_span[5·i] 分钟。 Limak 的朋友们正在举办跨年派对,Limak 希望能在午夜或之前到达。他从家出发前往派对需要 #cf_span[k] 分钟,而他将在家先参加竞赛。 如果 Limak 希望赶到派对,他最多能解决多少道题? 输入仅有一行,包含两个整数 #cf_span[n] 和 #cf_span[k](#cf_span[1 ≤ n ≤ 10],#cf_span[1 ≤ k ≤ 240]),分别表示竞赛中的题目数量和 Limak 从家到派对所需的时间(分钟)。 请输出一个整数,表示 Limak 能解决的最大题目数量,使得他能在午夜或之前到达派对。 在第一个样例中,共有 #cf_span[3] 道题,Limak 需要 #cf_span[222] 分钟到达派对。三道题分别需要 #cf_span[5]、#cf_span[10] 和 #cf_span[15] 分钟。Limak 可以花费 #cf_span[5 + 10 = 15] 分钟解决前两道题。然后在 20:15 离开家,经过 #cf_span[222] 分钟后于 23:57 到达派对。在这种情况下,Limak 解决了 #cf_span[2] 道题。他没有足够时间解决第 #cf_span[3] 道题,因此答案是 #cf_span[2]。 在第二个样例中,Limak 可以在 #cf_span[5 + 10 + 15 + 20 = 50] 分钟内解决全部 #cf_span[4] 道题。他在 20:50 离开家前往派对,恰好在午夜到达。 在第三个样例中,Limak 只需要 #cf_span[1] 分钟到达派对,他有足够时间解决全部 #cf_span[7] 道题。 ## Input 输入仅有一行,包含两个整数 #cf_span[n] 和 #cf_span[k](#cf_span[1 ≤ n ≤ 10],#cf_span[1 ≤ k ≤ 240]),分别表示竞赛中的题目数量和 Limak 从家到派对所需的时间(分钟)。 ## Output 请输出一个整数,表示 Limak 能解决的最大题目数量,使得他能在午夜或之前到达派对。 [samples] ## Note 在第一个样例中,共有 #cf_span[3] 道题,Limak 需要 #cf_span[222] 分钟到达派对。三道题分别需要 #cf_span[5]、#cf_span[10] 和 #cf_span[15] 分钟。Limak 可以花费 #cf_span[5 + 10 = 15] 分钟解决前两道题。然后在 20:15 离开家,经过 #cf_span[222] 分钟后于 23:57 到达派对。在这种情况下,Limak 解决了 #cf_span[2] 道题。他没有足够时间解决第 #cf_span[3] 道题,因此答案是 #cf_span[2]。 在第二个样例中,Limak 可以在 #cf_span[5 + 10 + 15 + 20 = 50] 分钟内解决全部 #cf_span[4] 道题。他在 20:50 离开家前往派对,恰好在午夜到达。 在第三个样例中,Limak 只需要 #cf_span[1] 分钟到达派对,他有足够时间解决全部 #cf_span[7] 道题。
**Definitions** Let $ n \in \mathbb{Z} $ be the number of problems. Let $ k \in \mathbb{Z} $ be the travel time (in minutes) to the party. Let $ t_i = 5i $ be the time (in minutes) required to solve problem $ i $, for $ i \in \{1, 2, \dots, n\} $. **Constraints** 1. $ 1 \leq n \leq 10 $ 2. $ 1 \leq k \leq 240 $ 3. Total available time: $ 240 $ minutes (from 20:00 to midnight). **Objective** Find the maximum integer $ m \in \{0, 1, \dots, n\} $ such that: $$ \sum_{i=1}^{m} 5i + k \leq 240 $$
Samples
Input #1
3 222
Output #1
2
Input #2
4 190
Output #2
4
Input #3
7 1
Output #3
7
API Response (JSON)
{
  "problem": {
    "name": "A. New Year and Hurry",
    "description": {
      "content": "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 difficul",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF750A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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 difficul...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Limak 将参加 2016 年最后一天的一场竞赛。比赛将于 20:00 开始,持续四小时,恰好到午夜结束。共有 #cf_span[n] 道题目,按难度排序,即第 #cf_span[1] 题最简单,第 #cf_span[n] 题最难。Limak 知道他解决第 #cf_span[i] 题需要 #cf_span[5·i] 分钟。\n\nLimak 的朋友们正在举办跨年派对,Limak 希望能在午夜或之前到...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of problems.  \nLet $ k \\in \\mathbb{Z} $ be the travel time (in minutes) to the party.  \nLet $ t_i = 5i $ be the time (in minutes) required to s...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments