【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;
}
相关文章
- Sereja and Suffixes
- A. The Fair Nut and Elevator (Codeforces Round #526 (Div. 2))
- A. Vova and Train ( Codeforces Round #515 (Div. 3) )
- 【论文阅读】DisenPOI Disentangling sequential and geographical influence for point-of-interest recommendat
- ORA-01378: The logical block size (string) of file string is not compatible with the disk sector size (media sector size is string and host sector size is string) ORACLE 报错 故障修复 远程处理
- ORA-26809: Capture aborted: checkpoint-free mode requires combined capture and apply mode. ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-010345; Symbol: ER_INVALID_CHARSET_AND_DEFAULT_IS_MB; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-13291: conversion error between the specified unit and standard unit ORACLE 报错 故障修复 远程处理
- ORA-13904: The file has been dropped and recreated during the procedure call. ORACLE 报错 故障修复 远程处理
- Oracle between and 边界问题详解编程语言
- MySQL中的OR与AND操作符比较(mysqlor和and)
- Linux TGZ: All You Need to Know About Tar and Gzip Compression!(linuxtgz)
- Maximizing System Performance: A Guide to Using Linux SAR for Monitoring and Analysis.(linuxsar)
- Oracle数据库中的AND查询(oracle and查询)
- MySQL中的AND和OR使用逻辑运算符优化查询语句(mysql中and与or)
- Oracle 数据库中使用AND拼接的威力(oracle中and拼接)