//Topcoder SRM 576 DIV 2 L1 TheExperimentDiv2
import java.util.*;
import java.math.*;
//rename the class name before submitting
public class TheExperimentDiv2 {
public static void main(String[] args) {
TheExperimentDiv2 obj = new TheExperimentDiv2();
Object o =
obj.determineHumidity(
new int[] { 3, 4, 1, 1, 5, 6 },
3,
new int[] { 3, 1, 0 }
);
System.out.println(o);
}
public int[] determineHumidity(int[] intensity, int L, int[] leftEnd) {
int M = leftEnd.length;
int[] sum = new int[M];
for (int i = 0; i < M; i++) {
sum[i] = 0;
for (int j = leftEnd[i]; j < leftEnd[i] + L; j++) {
sum[i] += intensity[j];
intensity[j] = 0;
}
}
return sum;
}
}
No comments:
Post a Comment