zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 31 A. Book Reading【暴力】

    A. Book Reading
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Input

    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.

    Output

    Print the minimum day Luba can finish reading the book.

    It is guaranteed that answer doesn't exceed n.

    Examples
    input
    2 2
    86400 86398
    output
    2
    input
    2 86400
    0 86400
    output
    1
    【题意】:给出总天数n,读书时间t。n天内的干活时间(按秒记,一天86400秒)。求最少的读完书的天数。
    【分析】:暴力。
    【代码】:
    #include <bits/stdc++.h>
    
    using namespace std;
    #define inf 1e18+100
    #define LL long long
    
    const int maxn = 86400+100;
    
    int main()
    {
        LL n,t,res; //给定时间,读书时间
        LL r;
        LL a[maxn];//干活时间 求花几天读书
        while(cin>>n>>t)//2 86400 //1 86399
       {
           res=0;
           for(int i=0;i<n;i++)
           {
               cin>>a[i];
               res+=(86400-a[i]);//86400-干活时间=留下的读书时间
               if(res>=t)//剩余读书时间》需求读书时间,则可以于这天读完,直接输出该天是第几天
               {
                   cout<<i+1<<endl;
                   return 0;
               }
           }
       }
    }
    View Code
  • 相关阅读:
    [转]ROS学习笔记十一:ROS中数据的记录与重放
    [转]百度Appollo无人车Perception Module 分析
    百度 Apollo无人车平台增加传感器
    [转]Ubuntu16.04安装搜狗输入法
    [转]Ubuntu16 压缩解压文件命令
    Baidu Apollo use: command " rosbag " not fonud
    nvidia-smi command not found Ubuntu 16.04
    启动Turtlesim,输入roscore命令,报错
    Linux系统下安装Nginx
    linux重启后JDk环境变量配置失效最终解决方案
  • 原文地址:https://www.cnblogs.com/Roni-i/p/7781006.html
Copyright © 2011-2022 走看看