Pagini recente » Cod sursa (job #2556358) | Cod sursa (job #1223405) | Cod sursa (job #1266352) | Cod sursa (job #1168125) | Cod sursa (job #1831112)
import java.util.Scanner;
import java.io.*;
public class Secv3 {
static short cost[], time[];
static int n, L, U, sumTime[], sumCost[];
static double ratio, max;
public static void main (String [] args) throws IOException{
Scanner input = new Scanner(new File("secv3.in"));
File fOut = new File("secv3.out");
FileWriter fwriter= new FileWriter(fOut);
PrintWriter output = new PrintWriter(fOut);
n = input.nextInt();
L = input.nextInt();
U = input.nextInt();
time = new short[n];
cost = new short[n];
sumCost = new int[n];
sumTime = new int[n];
for(int i = 0; i < n; i++)
cost[i] = input.nextShort();
for(int i = 0; i < n; i++)
time[i] = input.nextShort();
for(int i = 0; i < n; i++)
{
for(int j = 0; j < U && (i + j) < n; j++)
{
sumCost[i] += cost[i + j];
sumTime[i] += time[i + j];
}
ratio = (double) ((double)sumCost[i] / (double)sumTime[i]);
if(ratio > max) max = ratio;
}
U--;
while(U >= L)
{
for(int i = 0; i <= n; i++)
if((i + U) < n)
{
sumCost[i] -= cost[i + U];
sumTime[i] -= time[i + U];
ratio = (double) ((double)sumCost[i] / (double)sumTime[i]);
if(ratio > max) max = ratio;
}
U--;
}
output.println(String.format( "%.2f", max ));
output.close();
}
}