SIMULATION

포스트: 6
Tags

Posts

6 posts

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

TreasureHunt

불타는 아잍(IT)스크림|2019년 12월 20일

Code public class TreasureHunt{ int xLen,yLen; char[][] land; String[] inst; boolean instCheck(int x, int y) { int[] dx = {0,-1,1,0}; int[] dy = {-1,0,0,1}; for (int k = inst.length-1; k >= 0; k--) { char d = inst[k].charAt(0); int p = inst[k].charAt(2)-'0'; if (d == 'W') { while(p-->0)