SRM145

포스트: 3|조회수: 0|TERM
Items

Posts

3 posts

HillHike

Code public class HillHike{ public long numPaths(int distance, int maxHeight, int[] _landmarks) { long[][][] cache1 = new long[2][52][51]; long[][][] cache2 = new long[2][52][51]; cache1[0][0][0] = 1; int[] landmarks = new int[_landmarks.length+1]; System.arraycopy(_landmarks,0,landmarks,0,_landmarks.length); landmarks[_landmarks.length] = -1;

Bonuses

Code public class Bonuses{ public int[] getDivision(int[] points) { int len = points.length; int sum = 0, extra = 100; boolean[] used = new boolean[len]; int[] percents = new int[len]; for (int i = 0; i < len; i++) sum += points[i]; for (int i = 0; i

VendingMachine

Code public class VendingMachine{ int rows, cols; int ts; // a total of seconds int ci, cj; // current i, current j; int[][] p; void addSecs(int nj) { int a = Math.abs(nj - cj); int b = cols - Math.abs(nj - cj); ts += (a < b) ? a : b; } void setMaxCol() { int max = -1, mj = cj; for (int j = 0; j < cols