• 【模拟】Workout for a Dumbbell


    题目描述

    Jim Ratt has just joined a local fitness center. He’s especially excited about a sequence of 10 machines that he cycles through three times for his workout. He has a fixed time which he spends on each machine, as well as a fixed recovery time after using a machine. Jim’s not the brightest guy in the world, but in the absence of anything else even he would easily be able to calculate how long his workout would take. 
    But of course, Jim isn’t the only person who uses the fitness center and wouldn’t you know it but when Jim shows up there are always 10 other people there, each using one of the ten machines exclusively. Like Jim, each person has a fixed time they use on their machine as well as a fixed recovery time. This will sometimes cause Jim to have to wait for a particular machine, and Jim’s usage sometimes results in the other people having to wait as well (though if both Jim and another person want to start using a machine at the same time, Jim is polite enough to let the other person go first). Jim has gone to the center often enough that he has a good idea what everyone’s usage and recovery times are, but he has trouble determining how long it will take him to perform his workout. That’s where you are going to flex your programming muscles.

    输入

    Input starts with a line containing twenty integers; the first two give Jim’s usage and recovery time for machine 1, the next two give Jim’s usage and recovery time for machine 2, etc. The next line contains 3 integers u r t; the first two values are the usage and recovery times for the person who is using machine 1,and t is the time when he/she first starts using the machine. The next 9 lines specify similar information for machines 2 through 10. All usage and recovery times are positive and ≤ 5 000 000 and all start times t satisfy |t| ≤ 5 000 000. You should assume that Jim is ready to use machine 1 at time 0.

    输出

    Display the time when Jim has finished his workout, i.e., the moment when he has finished his usage time on machine 10 for the third time (don’t count the last recovery time for that machine).

    样例输入

    5 5 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    2 2 1
    8 3 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0
    1 1 0
    

    样例输出

    100
    

     

    #include <bits/stdc++.h>
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    using namespace std;
    int n,k;
    int ant,cnt;
    int w[10],r[10],st[10];
    int w0[10],r0[10];
    int t;
    int main()
    {
        for(int i=0; i<10; i++)
        {
            scanf("%d %d",&w0[i],&r0[i]);
        }
        for(int i=0; i<10; i++)
        {
            scanf("%d %d %d",&w[i],&r[i],&st[i]);
        }
        for(int q=0; q<3; q++)
        {
            for(int i=0; i<10; i++)
            {
                if(t>=st[i])
                {
                    int tmp=(t-st[i])%(w[i]+r[i]);
                    if(tmp>=w[i])
                    {
                        st[i]=max(t+w0[i],t+r[i]-(tmp-w[i]));
                        t+=w0[i];
                        t+=r0[i];
                    }
                    else
                    {
                        t+=w[i]-tmp;
                        st[i]=max(t+w0[i],t+r[i]);
                        t+=w0[i];
                        t+=r0[i];
                    }
                }
                else
                {
                    t+=w0[i];
                    if(t>st[i])
                    {
                        st[i]=t;
                    }
                    t+=r0[i];
                }
                //cout<<t<<" "<<st[i]<<endl;
            }
        }
        t-=r0[9];
        printf("%d
    ",t);
        return 0;
    }
  • 相关阅读:
    hdu 5877 (dfs+树状数组) Weak Pair
    hdu 5876 (补图BFS) Sparse Graph
    bzoj 1051 (强连通) 受欢迎的牛
    UVA 10054 (欧拉回路) The Necklace
    HYSBZ 2743 (树状数组) 采花
    Codeforces 702C Cellular Network
    ZAB协议(Zookeeper atomic Broadcast)
    分布式一致性协议-2PC与3PC(二)
    分布式架构(一)
    redis集群
  • 原文地址:https://www.cnblogs.com/Diliiiii/p/9582747.html
Copyright © 2020-2023  润新知