void main() { runSolver(); } void problem() { auto H = scan!int; auto W = scan!int; auto Y = scan!int; auto X = scan!int; auto A = scan!long(H * W).chunks(W).array; auto solve() { auto rect = GridPoint(W, H); auto visited = new bool[][](H, W); visited[Y-1][X-1] = true; alias Enemy = Tuple!(GridPoint, "p", long, "v"); auto q = DList!GridPoint([GridPoint(X - 1, Y - 1)]); long strength = A[Y-1][X-1]; auto heap = (new Enemy[](0)).heapify!"a.v > b.v"; while(true) { auto p = q.front; q.removeFront; foreach(a; p.around(rect)) { if (a.of(visited)) continue; visited[a.y][a.x] = true; heap.insert(Enemy(a, A[a.y][a.x])); } while(!heap.empty && heap.front.v < strength) { strength += heap.front.v; q.insertBack(heap.front.p); heap.removeFront; } if (heap.empty && q.empty) return YESNO[true]; if (!heap.empty && q.empty) return YESNO[false]; } return YESNO[false]; // dp.deb; // return YESNO[dp[$ - 1][$ - 1].maxElement > 0]; } outputForAtCoder(&solve); } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop; T[][] combinations(T)(T[] s, in long m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } T scan(T)(){ return scan.to!T; } T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; } void deb(T ...)(T t){ debug writeln(t); } long[] divisors(long n) { long[] ret; for (long i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array; } bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; } bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; } string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; } ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}} string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; } struct ModInt(uint MD) if (MD < int.max) {ulong v;this(string v) {this(v.to!long);}this(int v) {this(long(v));}this(long v) {this.v = (v%MD+MD)%MD;}void opAssign(long t) {v = (t%MD+MD)%MD;}static auto normS(ulong x) {return (x>>".writefln(benchmark!problem(1)); BORDER.writeln; } } else problem(); } enum YESNO = [true: "Yes", false: "No"]; // ----------------------------------------------- struct GridPoint { static enum ZERO = GridPoint(0, 0); int x, y; static GridPoint reversed(int y, int x) { return GridPoint(x, y); } this(int x, int y) { this.x = x; this.y = y; } inout GridPoint left() { return GridPoint(x - 1, y); } inout GridPoint right() { return GridPoint(x + 1, y); } inout GridPoint up() { return GridPoint(x, y - 1); } inout GridPoint down() { return GridPoint(x, y + 1); } inout GridPoint leftUp() { return GridPoint(x - 1, y - 1); } inout GridPoint leftDown() { return GridPoint(x - 1, y + 1); } inout GridPoint rightUp() { return GridPoint(x + 1, y - 1); } inout GridPoint rightDown() { return GridPoint(x + 1, y + 1); } inout GridPoint[] around() { return [left(), up(), right(), down()]; } inout GridPoint[] around(GridPoint max) { GridPoint[] ret; if (x > 0) ret ~= left; if(x < max.x-1) ret ~= right; if(y > 0) ret ~= up; if(y < max.y-1) ret ~= down; return ret; } inout T of(T)(inout ref T[][] grid) { return grid[y][x]; } }