Some solution examples of problems in topcoder, codeeval, google code jam, interviewstreet, onlinejudge-uva, codeforces, projecteuler, etc
Friday, March 15, 2013
Topcoder SRM 569 DIV 2, L2 TheJediTestDiv2
// Topcoder SRM 569 DIV 2, L2 TheJediTestDiv2
import java.util.*;
import java.math.*;
public class TheJediTestDiv2 {
public static void main(String[] args) {
System.out.println(
//
new TheJediTestDiv2().countSupervisors(
null,
1, 1
));
}
public int countSupervisors(int[] students, int Y, int J) {
int minJedi = Integer.MAX_VALUE;
for (int iy = 0; iy < students.length; iy++) {
int jd = 0;
int forj = students[iy] - Y;
if (forj > 0) {
jd += forj / J + (forj % J > 0 ? 1 : 0);
}
for (int j = 0; j < students.length; j++) {
if (j == iy)
continue;
forj = students[j];
jd += forj / J + (forj % J > 0 ? 1 : 0);
}
minJedi = Math.min(minJedi, jd);
}
return minJedi;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment