zoukankan      html  css  js  c++  java
  • 【模拟】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;
    }
  • 相关阅读:
    纷享销客公司产品能力学习笔记
    有质量的两道面试题
    java项目启动时执行指定方法
    css银行卡号样式
    swiper6使用鼠标滚轮失效退回swiper4即可
    vue-swiper Demo
    vue点击下载图片
    跨域请求发送数据在body里,java后台接收
    跨域,跨服务session获取不到,前后台不会传输Cookie,sessionId不一致
    Windows下 redis命令及配置
  • 原文地址:https://www.cnblogs.com/Diliiiii/p/9582747.html
Copyright © 2011-2022 走看看