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 ≤ 1001 ≤ 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 <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;
    }


    B. Japanese Crosswords Strike Back
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and ai is the length of i-th segment. No two segments touch or intersect.

    For example:

    • If x = 6 and the crossword is 111011, then its encoding is an array {3, 2};
    • If x = 8 and the crossword is 01101010, then its encoding is an array {2, 1, 1};
    • If x = 5 and the crossword is 11111, then its encoding is an array {5};
    • If x = 5 and the crossword is 00000, then its encoding is an empty array.

    Mishka wants to create a new one-dimensional Japanese crossword. He has already picked the length and the encoding for this crossword. And now he needs to check if there is exactly one crossword such that its length and encoding are equal to the length and encoding he picked. Help him to check it!

    Input

    The first line contains two integer numbers n and x (1 ≤ n ≤ 1000001 ≤ x ≤ 109) — the number of elements in the encoding and the length of the crossword Mishka picked.

    The second line contains n integer numbers a1a2, ..., an (1 ≤ ai ≤ 10000) — the encoding.

    Output

    Print YES if there exists exaclty one crossword with chosen length and encoding. Otherwise, print NO.

    Examples
    input
    2 4
    1 3
    
    output
    NO
    
    input
    3 10
    3 3 2
    
    output
    YES
    
    input
    2 10
    1 3
    
    output
    NO
    



    题意:

    给出一个二进制字符串 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题认真做的话可能可以做出来,只是时间问题

    还是太划水了,每次都是写完养生题就怠惰下去,态度需要转变!!!

    后面的题等一下有没有题解吧!

  • 相关阅读:
    java实现模拟登陆
    springboot整合kafka(转)
    springboot使用缓存(三)
    springboot使用缓存(二)
    springboot使用缓存(一)
    springboot日期入参出参格式化注解:@DateTimeFormat 和 @JsonFormat (转)
    H5调用android相机拍照
    时间复杂度
    java guide面试突击版
    java面试手册-复制内容
  • 原文地址:https://www.cnblogs.com/bryce1010/p/9387113.html
Copyright © 2011-2022 走看看