首页 > 其他分享 >ECNA 2017 Problem J: Workout for a Dumbbell 模拟

ECNA 2017 Problem J: Workout for a Dumbbell 模拟

时间:2023-04-24 23:37:39浏览次数:35  
标签:Dumbbell int Workout Jim long machine time 2017 include

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
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.
Output
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).
Sample Input 1 Sample Output 1
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

一个人在健身房运动,总共10个器材,除他以外还有10个人,每个人都有运动和休息时间,当然如果他目前位置的人和他在相同的时间用器械,他出于礼貌,会等他运动完才运动,求他第三次到达10号器材所需要的时间;

比较复杂的模拟;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<string>
#include<bitset>
#include<ctime>
#include<deque>
typedef long long ll;
using namespace std;
typedef unsigned long long int ull;
#define maxn 30005
#define ms(x) memset(x,0,sizeof(x))
#define Inf 0x7fffffff
#define inf 0x3f3f3f3f
const long long int mod = 1e9 + 7;
#define pi acos(-1.0)
#define pii pair<int,int>
#define eps 1e-7
#define pll pair<ll,ll>



ll quickpow(ll a, ll b) {
    ll ans = 1;
    a = a % mod;
    while (b > 0) {
        if (b % 2)ans = ans * a;
        b = b / 2;
        a = a * a;
    }
    return ans;
}

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a%b);
}

int use[maxn], rec[maxn];
int uu[maxn], rr[maxn], t[maxn];


int main()
{
    ios::sync_with_stdio(false);
    int i, j;
    for (i = 1; i <= 10; i++) {
        cin >> use[i] >> rec[i];
    }
    int sum = 0;
    for (i = 1; i <= 10; i++) {
        cin >> uu[i] >> rr[i] >> t[i];
    }
    for (i = 1; i <= 30; i++) {
        if (i % 10 == 0)j = 10;
        else j = i % 10;
        if (sum >= t[j]) {
            int dlt = sum - t[j];
            int k = dlt / (uu[j] + rr[j])*(uu[j] + rr[j]);
            t[j] += (k + uu[j]);
            sum = max(sum, t[j]);
            t[j] += rr[j];
        }
        sum += use[j];
        t[j] = max(t[j], sum);
        sum += rec[j];
    }
    cout << sum - rec[10] << endl;
}

标签:Dumbbell,int,Workout,Jim,long,machine,time,2017,include
From: https://blog.51cto.com/u_15657999/6221988

相关文章

  • 2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)C - Counting Stars 暴力三元环
    LittleAisanastronomylover,andhehasfoundthattheskywassobeautiful!Soheiscountingstarsnow!Therearenstarsinthesky,andlittleAhasconnectedthembymnon-directionaledges.Itisguranteedthatnoedgesconnectonestarwithi......
  • ECNA 2017 Problem G: A Question of Ingestion DP
    StanFordisatypicalcollegegraduatestudent,meaningthatoneofthemostimportantthingsonhismindiswherehisnextmealwillbe.Fortunehassmiledonhimashe’sbeeninvitedtoamulti-coursebarbecueputonbysomeofthecorporatesponsors......
  • Nordic Collegiate Programming Contest (NCPC) 2017 C 在线查询,更新
    Onehundredyearsfromnow,in2117,theInternationalCollegiateProgrammingContest(ofwhichtheNCPCisapart)hasexpandedsignificantlyanditisnowtheGalacticCollegiateProgrammingContest(GCPC).Thisyeartherearenteamsinthecontest.T......
  • The 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
    ThetunnelsofCuChiareanimmensenetworkofundergroundtunnelsconnectingroomslocatedintheCuChiDistrictofHoChiMinhCity.TheCuChitunnelswerethelocationofseveralmilitarycampaignsinthe1960s.Nowadays,itisapopulartouristdes......
  • 为什么2017年之后操作系统仍将扮演重要角色?
    操作系统的历史虽然不像计算科学那么久远,但却也已经拥有相当可观的发展历程。大型机客户于上世纪五十年代末编写了第一批操作系统,这些系统直到数十年后的今天仍拥有相当的知名度——其中包括来自IBM公司的OS/360以及贝尔实验室打造的Unix。在可预期的未来,操作系统仍将继续......
  • 为什么2017年之后操作系统仍将扮演重要角色?
    操作系统的历史虽然不像计算科学那么久远,但却也已经拥有相当可观的发展历程。大型机客户于上世纪五十年代末编写了第一批操作系统,这些系统直到数十年后的今天仍拥有相当的知名度——其中包括来自IBM公司的OS/360以及贝尔实验室打造的Unix。在可预期的未来,操作系统仍将继续......
  • 为什么2017年之后操作系统仍将扮演重要角色?
    操作系统的历史虽然不像计算科学那么久远,但却也已经拥有相当可观的发展历程。大型机客户于上世纪五十年代末编写了第一批操作系统,这些系统直到数十年后的今天仍拥有相当的知名度——其中包括来自IBM公司的OS/360以及贝尔实验室打造的Unix。在可预期的未来,操作系统仍将继续......
  • 【230417-1】三种方法解方程:(x-2017)(x-2021)=12
    ......
  • Linux 基金会发布 2017 最佳 Linux 发行名单
    Linux 基金会官网Linux.com近日发布了一篇名为“2017年最佳Linux发行版”的文章,并表示这些是从数百个发行版中发现的最好的Linux发行版。1、最佳系统管理员发行版:ParrotLinux2、最近轻量级发行版:LXLE3、最佳桌面发行版:ElementaryOS4、最佳验证发行版:Gentoo......
  • Linux 基金会发布 2017 最佳 Linux 发行名单
    Linux 基金会官网Linux.com近日发布了一篇名为“2017年最佳Linux发行版”的文章,并表示这些是从数百个发行版中发现的最好的Linux发行版。1、最佳系统管理员发行版:ParrotLinux2、最近轻量级发行版:LXLE3、最佳桌面发行版:ElementaryOS4、最佳验证发行版:Gentoo......