Home > Back-end >  ACM submitted in Time Limit Exceed, everybody to help, submit the countless times
ACM submitted in Time Limit Exceed, everybody to help, submit the countless times

Time:09-26

The original: http://172.20.23.234/JudgeOnline/showproblem? Problem_id=1079
Known each thread starting from the specified position and the content behind the order download, when arrived at the position of a already downloaded thread stops, the assumption in the process of the download speed is constant, now the size of the given file (KB), each thread starting position (percentage) and download speed (KB/s), I want to know how long will it take to download,
Input
Start a number T (T<=100), said the data on the number of groups,
Each group of data begins with two integers, N (1 & lt;=N<=100000), said the number of threads, M (0 & lt; M & lt;=10 ^ 9) the size of the said documents,
And then N lines, each line had two decimal, starting position percentage P (0 & lt;=P & lt; 100), thread download speed V (0 & lt; V & lt;=10000), the original position of the input to ensure at least one thread to 0, and the starting position is different, each thread
The Output
Output a line, each group of data format for "Case # c: K c says the number of sets of sample, K said need download time, retain two decimal places,
The Sample Input
2
2 1000
0 to 50
50 40
3 59644
0 to 35
90, 64,
50 100

The Sample Output
Case # 1:12.50
Case # 2:852.06
My code is as follows:
#include
#include
#include
Using namespace STD.
Void main ()
{
int T;
Double * p, * v.
Cin> T;
Int N, M;
Double Max;
for(int i=1; i<=T; I++)
{
Double n=0;
Double m=0;
Max=0;
Cin> N> M;
P=new double [N].
V=new double [N].
For (int y=0; Y{
Cin> P [y] & gt;> V [y];
}

for(int j=1; j<=N - 1; J++)
{
For (int k=0; K{
If (p [k] & gt; P (k + 1])
{
M=p (k + 1),
P=p (k + 1] [k].
P=m [k];
N=v (k + 1),
V (k + 1)=v (k);
V [k]=n;
}
}}

Double r=100.0 M/;
For (int x=1; x{
Double q=(r * (p - p [1] x [x]))/v (x - 1),
Max=q> Max? Q: Max;
If (x==N - 1)
{
Double l=r * (100 - p [x])/v (x),
Max=l> Max? L: Max;
}
}
Cout<" Case# "& lt;
}
}
?
  • Related