#include <bits/stdc++.h> using namespace std; #define int int64_t typedef array<int, 2> pii; int fits_donut(int dx, int dy, int rmin, int rmax){ //cerr << "fits_donut(" << dx << " " << dy << " " << rmin << " " << rmax << endl; dx = abs(dx); dy = abs(dy); if(dx > rmax || dy > rmax) return 0; // outside if(dx < rmin && dy < rmin) return 2; // too inside //cerr << "returned yes" << endl; return 1; } int32_t main(){ int n; cin >> n; int x_real, y_real; cin >> x_real >> y_real; int x = x_real + y_real, y = x_real - y_real; vector<pii> r(n-1); for(int i = 0; i < n-1; ++i){ cin >> r[i][0]; r[i][1] = i; } sort(r.begin(), r.end(), [&](pii a, pii b){return a[0] > b[0];}); r.push_back({0, n-1}); // dummy vector<pii> raw_ans(n); int sum = 0; for(int i = 1; i < n-1; ++i) sum += r[i][0]; if(1 != fits_donut(x, y, r[0][0] - sum, r[0][0] + sum)){ cout << "NO" << endl; return 0; } cout << "YES\n0 0" << endl; for(int i = 0; i < n-1; ++i){ // intersect square i and donut i+1..n sum -= r[i+1][0]; int rmin = r[i+1][0] - sum; int rmax = r[i+1][0] + sum; // square 0, 0, r[i][0] // donut x, y, rmin, rmax int ri = r[i][0]; int done = 0; int chosen_dx = 0, chosen_dy = 0; int pmr[] = {-ri, +ri}; int rets[2][2]; //cerr << "i = " << i << " ri = " << ri << " x = " << x << " y = " << y << " rmin = " << rmin << " rmax = " << rmax << endl; for(int ix = 0; ix < 2; ++ix){ for(int iy = 0; iy < 2; ++iy){ int xp = pmr[ix], yp = pmr[iy]; int ret = fits_donut(x-xp, y-yp, rmin, rmax); if(ret == 1) done = 1, chosen_dx = xp, chosen_dy = yp; rets[ix][iy] = ret; } } //cerr << "rets " << rets[0][0] << " " << rets[0][1] << " " << rets[1][0] << " " << rets[1][1] << endl; auto try_choose = [&](int dx, int dy){ if(done) return; if((dx + dy) & 1) return; // not an integer point if(dx > ri || dy > ri || dx < -ri || dy < -ri) return; // outside of square if(!(abs(dx) == ri || abs(dy) == ri)) return; // inside of square if(1 == fits_donut(x-dx, y-dy, rmin, rmax)) done = 1, chosen_dx = dx, chosen_dy = dy; }; if(!done){ // try the segments // left segment try_choose(-ri, y-rmax); try_choose(-ri, y-rmax+1); try_choose(-ri, y+rmax-1); try_choose(-ri, y+rmax); // right segment try_choose(ri, y-rmax); try_choose(ri, y-rmax+1); try_choose(ri, y+rmax-1); try_choose(ri, y+rmax); // bottom segment try_choose(x-rmax, -ri); try_choose(x-rmax+1, -ri); try_choose(x+rmax-1, -ri); try_choose(x+rmax, -ri); // top segment try_choose(x-rmax, ri); try_choose(x-rmax+1, ri); try_choose(x+rmax-1, ri); try_choose(x+rmax, ri); } // if(!done) //cerr << "porcoddio" << endl; int original_idx = r[i][1]; raw_ans[original_idx] = {chosen_dx, chosen_dy}; x -= chosen_dx; y -= chosen_dy; } int sumx = 0, sumy = 0; for(int i = 0; i < n-1; ++i){ auto [tdx, tdy] = raw_ans[i]; int dx = (tdx + tdy)/2; int dy = (tdx - tdy)/2; sumx += dx; sumy += dy; cout << sumx << " " << sumy << endl; } }