import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; /** * yukicoder no.20 * @author scache * */ public class OasisInDesert { public static void main(String[] args) { OasisInDesert p = new OasisInDesert(); } public OasisInDesert() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int v = sc.nextInt(); int oy = sc.nextInt()-1; int ox = sc.nextInt()-1; Point[][] map = new Point[n][n]; for(int i=0;idistance){ System.out.println("YES"); return; } if(ox<0 && oy<0){ System.out.println("NO"); return; } int oDistance = dijstra(map, 0, 0, ox, oy); int gDistance = dijstra(map, ox, oy, map.length-1, map.length-1); if( (v-oDistance)*2>gDistance){ System.out.println("YES"); return; } System.out.println("NO"); } int[] dx = {-1, 0, 1, 0}; int[] dy = {0, -1, 0, 1}; private int dijstra(Point[][] map, int sx, int sy, int tx, int ty){ PriorityQueue queue = new PriorityQueue(); int[][] distances = new int[map.length][map.length]; for(int i=0;i distances[p.x][p.y] + map[nx][ny].d){ distances[nx][ny] = distances[p.x][p.y] + map[nx][ny].d; queue.offer(new Point(nx, ny, distances[nx][ny])); } } } } return distances[tx][ty]; } private class Point implements Comparable{ public int x; public int y; public int d; public Point(int x, int y, int d){ this.x = x; this.y = y; this.d = d; } @Override public int compareTo(Point arg0) { return d-arg0.d; } } }