http://codeforces.com/problemset/problem/596/C

题目大意:  给你n个数对  确保如果(x,y)存在这个集合  那么  0<=x'<=x && 0<=y'<=y (x',y')也一定存在这个集合    他们规定 i的美观值=(y-x)   还会给你一个美观值序列   每一个如果都有唯一一个i与之匹配   并且 这个集合后面的所有数都不能小于前面的数  也就是说(

a[s[i]].x<=a[s[i-1]].x && a[s[i]].y<=a[s[i-1]].y

分析:   我觉得应该先对a数组从小到大排序  这样避免以后在比较的时候出现错误

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<iostream> using namespace std;
#define N 500050
const double ESP = 1e-;
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a)) int s[N]; struct node
{
int x,y;
}a[N];
struct Node
{
int v,k;
}b[N],c[N]; int cmp(Node p,Node q)
{
if(p.v!=q.v)
return p.v<q.v;
else
return p.k<q.k;
} int cmp1(node p,node q)
{
if(p.x!=q.x)
return p.x<q.x;
else
return p.y<q.y;
} int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(s,);
memset(a,);
memset(b,);
memset(c,);
for(int i=;i<n;i++)
{
scanf("%d %d",&a[i].x,&a[i].y);
}
sort(a,a+n,cmp1);
for(int i=;i<n;i++)
{
c[i].v=a[i].y-a[i].x;
c[i].k=i;
}
for(int i=;i<n;i++)
{
scanf("%d",&b[i].v);
b[i].k=i;
}
sort(b,b+n,cmp);
sort(c,c+n,cmp);
int flag=;
for(int i=;i<n;i++)
{
if(b[i].v!=c[i].v)
{
flag=;
break;
}
else
{
s[b[i].k]=c[i].k;
}
}
for(int i=;i<n;i++)
{
if(a[s[i]].x<=a[s[i-]].x && a[s[i]].y<=a[s[i-]].y)
flag=;
if(flag==)
break;
}
if(flag==)
printf("NO\n");
else
{
printf("YES\n");
for(int i=;i<n;i++)
{
printf("%d %d\n",a[s[i]].x,a[s[i]].y);
}
}
}
return ;
}

C. Wilbur and Points---cf596C的更多相关文章

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

    C. Wilbur and Points time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

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

    C. Wilbur and Points Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/ ...

  3. 【26.67%】【codeforces 596C】Wilbur and Points

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. CodeForces 596C Wilbur and Points

    先对n个点分类,然后按题意要求构造,构造的时候判断这个点的右上方之前是否有点,判断可以用线段树来操作. #include<cstdio> #include<cstring> # ...

  5. Codeforces Round #331 (Div. 2)

    水 A - Wilbur and Swimming Pool 自从打完北京区域赛,对矩形有种莫名的恐惧.. #include <bits/stdc++.h> using namespace ...

  6. Codeforce#331 (Div. 2) A. Wilbur and Swimming Pool(谨以此题来纪念我的愚蠢)

    C time limit per test 1 second memory limit per test 256 megabytes input standard input output stand ...

  7. Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题

    A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  8. Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool

    A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input s ...

  9. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  10. [LeetCode] Max Points on a Line 共线点个数

    Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...

随机推荐

  1. hdu 3232 Crossing Rivers 过河(数学期望)

    题意:你在点A,目的地是点B,A和B的距离为D.中间隔了好多条河(所有河不会重叠),每条河有3个参数(P,L,V),其中P表示距离A点的长度,L表示河的长度,V表示河里的船的速度.假设每条河中仅有1条 ...

  2. [整理]ADB命令行学习笔记

    global driver# 元素定位driver.find_element_by_id("id") # id定位driver.find_element_by_name(" ...

  3. 框模型中设置内容区域元素占地尺寸box-sizing属性

    盒子模型有两种 一种是 内容盒子模型(content-box)一种是边框盒子模型(border-box). content-box:设置的尺寸,只设置内容区域, 左外边距+左边框+左内边距+内容区域宽 ...

  4. 如何移除浏览器一启动就打开lunchpage.org

    lunchpage.org 就是一个劫持网站.症状就是你打开你电脑上的任何浏览器都会重定向到一个广告页面.这个很烦! 解决方法: 1. 安装 Zemana AntiMalware 便携版. 2. 打开 ...

  5. 在docker中部署nginx

    1端口映射 大写P  为容器暴漏的所有端口进行映射   -p ,--publish-all=true    docker run -P -it centos  /bin/bash 小写p  指定哪些容 ...

  6. spring-mvc jackson配置json为空不输出

    使用的spring-mvc版本是4.1.6,jackson版本是2.1.4 在spring-mvc配置文件中添加以下代码就行 <mvc:annotation-driven> <mvc ...

  7. 基于tiny4412的u-boot移植(二)(转)

    http://www.cnblogs.com/pengdonglin137/archive/2015/12/27/5080645.html

  8. LeetCode(18)4Sum

    题目 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = ...

  9. LeetCode(14)Longest Common Prefix

    题目 Write a function to find the longest common prefix string amongst an array of strings. 分析 该题目是求一个 ...

  10. 杭电 1260 Tickets

    Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this ...