Recently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of n next days. The number of seconds that Luba has to spend working during i-th day is ai. If some free time remains, she can spend it on reading.
Help Luba to determine the minimum number of day when she finishes reading.
It is guaranteed that the answer doesn't exceed n.
Remember that there are 86400 seconds in a day.
The first line contains two integers n and t (1 ≤ n ≤ 100, 1 ≤ t ≤ 106) — the number of days and the time required to read the book.
The second line contains n integers ai (0 ≤ ai ≤ 86400) — the time Luba has to spend on her work during i-th day.
Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed n.
2 2 86400 86398
2
2 86400 0 86400
1
题意:
给出天数和阅读书本所需要的秒数
再给出每天有多少工作时间 计算每天的空余时间
#include <iostream>
using namespace std;
int main()
{
int n,t;
cin>>n>>t;
int ti;
int tmp=0;
int sum=0;
int i;
for( i=0;i<n;i++)
{
cin>>ti;
tmp+=86400-ti;
if(tmp>=t)
break;
}
cout<<i+1<<endl;
return 0;
}
题意:
给出一个二进制字符串 1的位置会被记录,连续的1当作同一位置
问你给出的样例中是否满足只能构造唯一的字符串
思路:
很简单,唯一的字符串是每一个区域“1”的间隔之间必须是一个“0”
所以间隔的个数加上所有1的数量就等于字符串的长度,这时候有唯一解
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
ll n,x;
cin>>n>>x;
ll sum=0;
ll a;
for(ll i=0;i<n;i++)
{
cin>>a;
sum+=a;
}
if(sum+n-1==x)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
其他的题C、D题认真做的话可能可以做出来,只是时间问题
还是太划水了,每次都是写完养生题就怠惰下去,态度需要转变!!!
后面的题等一下有没有题解吧!