zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 31

    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

     直接模拟下最好

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,k;
        cin>>n>>k;
        for(int i=1;i<=n;i++)
        {
            int x;
            cin>>x;
            k-=86400-x;
            if(k<=0)
            {
                cout<<i<<endl;
                return 0;
            }
        }
        return 0;
    }
  • 相关阅读:
    PHP开发者的MySQL错误
    shell编程技术和实例《linux0.01内核分析与操作系统设计》
    函数问题1 init_EMUX
    sizeof问题
    C语言读书心得
    《深入浅出MFC》读书感受
    计算机专业学习多年的苦恼
    一个完整的字符设备驱动程序导读
    学习书籍选择
    鼠标滑动、文本添加(倒计时)
  • 原文地址:https://www.cnblogs.com/BobHuang/p/7755786.html
Copyright © 2011-2022 走看看