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<bits/stdc++.h>
using namespace std;
int n,k;
int a[105];
int main()
{
while(cin>>n>>k)//工作天数,读书需要的总时间
{
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);//每天的工作时间
}
int m=0,z;//天数,每天剩余时间
for(int i=0; i<n; i++)
{
z=86400-a[i];//每天的剩余时间
k-=z;//每天读完书后剩余阅读量
m++;//天数+1
if(k<=0)//读完这本书
{
printf("%d\n",m);//输出天数
break;
}
}
}
return 0;
}
本文描述了一个关于如何在有限的时间内完成阅读任务的同时,平衡每日工作的算法实现。主人公Luba需要在连续的若干天内分配时间给工作和阅读,目标是在最短的时间内完成一本书的阅读。文章提供了一段C++代码,用于计算并输出Luba可以在哪一天完成阅读。
958

被折叠的 条评论
为什么被折叠?



