## Yedl的专栏

Stay hungry, stay foolish

# Codeforces Round #331 (Div. 2) C. Wilbur and Points

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n;
struct node
{
int x, y, v, id, rt;
};
node p1[N], p2[N];

bool cmp1(node a, node b)
{
if(a.v != b.v) return a.v < b.v;
else
{
if(a.x != b.x) return a.x < b.x;
else return a.y < b.y;
}
}

bool cmp2(node a, node b)
{
if(a.v != b.v) return a.v < b.v;
else return a.id < b.id;
}

bool cmp3(node a, node b)
{
return a.id < b.id;
}

int main()
{
while(~scanf("%d", &n))
{
for(int i = 0; i < n; i++)
{
scanf("%d%d", &p1[i].x, &p1[i].y);
p1[i].v = p1[i].y - p1[i].x;
p1[i].id = i;
}
sort(p1, p1 + n, cmp1);
for(int i = 0; i < n; i++)
{
scanf("%d", &p2[i].v);
p2[i].id = i;
}
sort(p2, p2 + n, cmp2);
bool flag = false;
for(int i = 0; i < n; i++)
{
if(p1[i].v != p2[i].v)
{
flag = 1; break;
}
else p2[i].rt = p1[i].id;
}
if(flag)
{
puts("NO"); continue;
}
else
{
sort(p1, p1 + n, cmp3);
sort(p2, p2 + n, cmp3);
for(int i = 1; i < n; i++)
{
if(!(p1[p2[i].rt].x > p1[p2[i - 1].rt].x || p1[p2[i].rt].y > p1[p2[i - 1].rt].y))
{
flag = 1; break;
}
}
if(flag)
{
puts("NO"); continue;
}
else
{
puts("YES");
for(int i = 0; i < n; i++)
{
printf("%d %d\n", p1[p2[i].rt].x, p1[p2[i].rt].y);
}
}
}
}
return 0;
} 

#### Codeforces Round #471 div.2 ABC题解

2018-03-24 14:16:58

#### Codeforces Round #465 (Div. 2) C. Fifa and Fafa(圆问题，数论)

2018-02-20 16:16:48

#### Codeforces Round #377 (Div. 2)C. Sanatorium(贪心）

2016-10-26 20:08:59

#### Codeforces Round #447 (Div. 2) C. Marco and GCD Sequence (构造 贪心)

2017-11-20 13:19:26

#### Codeforces Round #482 (Div. 2)

2018-05-15 12:51:24

#### Codeforces Round #480 (Div. 2): C. Posterized（贪心）

2018-05-09 17:11:24

#### Educational Codeforces Round 35 (Rated for Div. 2) A——C

2017-12-29 00:06:09

#### Tinkoff Internship Warmup Round 2018 and Codeforces Round #475 (Div. 2) C. Alternating Sum

2018-04-18 11:14:58

#### Codeforces Round #462 (Div. 2)

2018-02-15 00:17:30

#### CF-Codeforces Round #483 (Div. 2) A~D

2018-05-16 00:48:25