LibreOJ #6162. "Meituan CodeM Preliminary Round A" Physical Training [Violence]

"Meituan CodeM Preliminary Round A" Physical Training

Problem Description

The delivery staff of Meituan Takeaway uses variable speed running for physical training. The way they train is: n people run in a line, with a distance of u meters between them, and each person's normal speed is v meters per second. When a delivery person is at the end of the line, he needs to run forward at his highest speed at that time until he surpasses the person at the front by u meters, and then drops back to the original speed v meters per second. Each person's initial maximum speed is c(i) m/s, and each round decays by d(i) m/s, that is, if i is the jth runner, then his speed is c(i)-( j-1) x d(i) m/s.
Initially n people are arranged in random order, and the probability of each order is exactly equal. What is the expected time required to run a round (everyone catches up to the top once, and the sequence returns to the original)?

Input data

The first line is integer n, real number v, and real number u;
the second line is n real numbers, each person's speed c(i);
the third line is n real numbers, each person's attenuation d(i);
the input data guarantees each person's speed does not decay to ≤v

Output Data

Answer to 3 decimal places.

input sample

10 37.618 0.422
72.865 126.767 202.680 106.102 99.516 134.418 167.952 173.646 120.210
136.571
2.941 3.664 7.363 4.161 0.246 8.046 5.521 7.473 7.178 5.649

Sample output

0.815

data range

n≤1000, v≤100, u≤10
c(i)≤50000, d(i)≤10
Input data to ensure that everyone's speed will not decay to ≤v

answer

Very watery little question, enumeration i starts at that point, and then counts expectations.

code show as below

#include<cstdio>
using namespace std;
int n;
double v,u,c[1005],d[1005],Ans;
int main(){
    scanf("%d%lf%lf",&n,&v,&u);
    for(int i=1;i<=n;i++) scanf("%lf",&c[i]);
    for(int i=1;i<=n;i++) scanf("%lf",&d[i]);
    for(int i=1;i<=n;i++){
        double Now=0;
        for(int j=1;j<=n;j++) Now+=(u*(double)n)/(c[i]-d[i]*(j-1)-v);
        Now/=n;Ans+=Now;
    }
    printf("%.3lf",Ans);
    return 0;
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326842143&siteId=291194637