B - Turn the Rectangles

【音视频处理】MP4、FLV、HLS适用范围,在线视频播放哪个更好 本期我们讨论在线点播的视频格式,对比这些视频格式的优劣以及原因 1、封装格式的作用 2、MP4 3、FLV 4、HLS 阅读详情

B - Turn the Rectangles

There are nn rectangles in a row. You can either turn each rectangle by 9090 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can turn all or none of them. You can not change the order of the rectangles.

Find out if there is a way to make the rectangles go in order of non-ascending height. In other words, after all the turns, a height of every rectangle has to be not greater than the height of the previous rectangle (if it is such).

Input

The first line contains a single integer nn (1≤n≤1051≤n≤105) — the number of rectangles.

Each of the next nn lines contains two integers wiwi and hihi (1≤wi,hi≤1091≤wi,hi≤109) — the width and the height of the ii-th rectangle.

Output

Print "YES" (without quotes) if there is a way to make the rectangles go in order of non-ascending height, otherwise print "NO".

You can print each letter in any case (upper or lower).

Examples

Input

3
3 4
4 6
3 5

Output

YES

Input

2
3 4
5 5

Output

NO

Note

In the first test, you can rotate the second and the third rectangles so that the heights will be [4, 4, 3].

In the second test, there is no way the second rectangle will be not higher than the first one.

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
 
int n, v, x, z, y, i;
int main()
{
	cin >> n;
	z = 2000000000;
	for (i = 0; i<n; i++)
	{
		cin >> x >> y;
		if (x < y)
		{
			swap(x, y);
		}
		if (x <= z)
		{
			z = x;
		}
		else
		{
			if (y <= z)
			{
				z = y;
			}
			else 
			{
				cout << "NO"<<endl; 
				return 0; 
			}
		}
	}
	cout << "YES"<<endl;
	return 0;
}

YOLOv8模型INT8量化实战:解决sigmoid输出归零的坑(附代码修改) 本文详细介绍了YOLOv8模型INT8量化过程中遇到的sigmoid输出归零问题及其解决方案。通过修改模型导出代码、优化ONNX量化流程,并提供完整的部署优化技巧,帮助开发者在边缘计算设备上实现高效的模型推理。文章还包含量化效果验证和常见问题排查方法,助力开发者快速解决实际部署中的难题。 阅读详情

相关推荐

win2012 r2 + IIS8.5 伪静态设置脚本映射

win2012 r2 + IIS8.5 伪静态设置脚本映射,网站用的.net fromwork 2.0 ,应用程序池设置了32位支持

xueking87的专栏 3240

CodeForces - 1008B Turn the Rectangles 思维

CodeForces - 1008B Turn the Rectangles 题意: 给你n个矩形的宽和高,每一个矩形可以旋转90度(宽和高互换),问能否使每个矩形的高不大于前一个举行的高 思路: 将第一个矩形的最长边当作高,往后的每一个矩形在不大于前一个矩形的高的前提下 把满足条件最长的那条边当作高,如果又不满足条件的就标记一下 #include&lt;iostream&gt; #i...

没有梦想何以远行 220

保姆级教程:用Multisim仿真快速上手二极管、MOSFET和IGBT的开关特性

本文提供了一份详细的Multisim仿真教程,帮助读者快速掌握二极管、MOSFET和IGBT的开关特性。通过搭建实验电路、观察波形特征和参数影响分析,深入解析了反向恢复过程、米勒平台现象和拖尾电流效应。适合电力电子初学者和工程师通过仿真建立直观理解,提升电路设计能力。

weixin_29290863的博客 498

1008B Turn the Rectangles

B. Turn the Rectanglestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn rectangles in a row. You can either turn each rectangle by 9090...

memory_qianxiao的博客 584

SAP_ABAP_MM_BAPI清单案例教程——采购发票校验/预制_BAPI_INCOMINGINVOICE_PARK_MIRO

SAP ABAP BAPI_INCOMINGINVOICE_PARK BAPI 采购发票预制 采购发票校验 代码模版

java_zhong1990的专栏 1963

【北大核心-代码复现】基于 VMD-FFCM-iTransformer 光伏功率短期预测

【北大核心-代码复现】基于 VMD-FFCM-iTransformer 光伏功率短期预测

766

B. Turn the Rectangles

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn rectangles in a row. You can either turn each rectangle by 9090 degre...

无知的我 521

手把手教你使用YOLOv11完成人脸分类识别,YOLOv11人脸识别,解决中文乱码问题,全网最详细教程

手把手教你使用YOLOv11完成人脸分类识别,YOLOv11人脸识别,解决中文乱码问题,全网最详细教程

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 4445

【水题】CodeForce 1008B Turn the Rectangles

这段时间要沉迷刷题一段时间了,就让优快云陪我一起吧! 一、题目大意 题目的意思大致就是,给你n个矩形的长和宽,每一个矩形可以进行90度旋转或不转,旋转过后宽和高会互换,求问给定n个矩形的长和宽,是否可以通过旋转使这n个矩阵的高保证不增序排列,即每一个矩形的高一定小于等于其前一个矩形的高。 二、题目思路以及AC代码 这题是一个很简单的贪心,贪心策略很简单,只要保证每次把宽和高两个值中小于等于前...

Johnson的博客 194

PCL点云DBSCAN聚类算法:基于密度的点云聚类

核心点是在给定半径内拥有足够多邻居点的点,边界点是在给定半径内没有足够多邻居点但是位于核心点的邻域内的点,噪声点是既不是核心点也不是边界点的点。本文将介绍PCL中的DBSCAN(基于密度的空间聚类应用噪声)算法,用于点云数据的聚类。上述示例代码首先从PCD文件中读取点云数据,并设置了DBSCAN聚类的参数,包括邻域搜索半径(epsilon)和邻域内最小点数(min_points)。需要注意的是,示例代码中的点云数据格式为pcl::PointXYZ,如果使用其他类型的点云数据,需要相应地修改代码。

LpmShell的博客 1239

Python爬虫技术应用:体育赛事直播数据抓取与分析

Web爬虫(Web Crawling)是一种通过模拟浏览器行为从网站获取数据的技术。发送请求:发送HTTP请求(通常是GET或POST请求)获取目标网页的HTML内容。解析网页:使用解析工具(如lxml)从HTML中提取出所需要的信息。存储数据:将抓取到的数据存储到数据库、文件或数据结构中,供后续分析和使用。数据分析与展示:使用数据分析工具(如PandasMatplotlib)对数据进行处理、清洗和可视化,生成有价值的报告和图表。Requests:用于发送静态网页的HTTP请求并获取响应。

2201_76125261的博客 1309

B. Turn the Rectangles 贪心模拟(较水)

There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice ...

loooooog的博客 306

【论文硬核拆解】Ctx2Skill:让大模型自己跟自己玩,从上下文里「进化」出可复用技能

论文选择自然语言技能可解释性:技能是人类可读的 Markdown 文件,可以审查、编辑、调试可迁移性:即插即用,从一个模型到另一个模型无需参数访问:对闭源模型友好这比 SKILL0/SkillRL 等参数内化方法更实用,尤其是在商业 API 场景。

步子哥的博客 155

CodeForces 1008B Turn the Rectangles

There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that yo...

codertcm的博客 268

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Turn the Rectangles(CodeForces 1008B)

There are nn rectangles in a row. You can either turn each rectangle by 9090 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that ...

Baiyi_destroyer的博客 246

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

B - Turn the Rectangles(贪心)

There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that yo...

码农的一亩三分地 334

Turn the Rectangles 1008B

output standard output There arennrectangles in a row. You can either turn each rectangle by9090degrees or leave it as it is. If you turn a rectangle, its width will be height, and its h...

weixin_30724853的博客 112

codeforces 解题报告 1008B. Turn the Rectangles 暴力贪心

http://codeforces.com/contest/1008/problem/B解题思路:1.可以交换每一行的两个数,最终使得右边那列非增2.暴力遍历,以行为组,在不大于前一组的前提下,使得 h[i] 取两数中较大值3.最后检查序列是否非增即可import java.util.Scanner; public class Main { public static void mai...

三生锁链 409

Turn the Rectangles(CF-1008B)

Problem Description There are nrectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be ...

Alex_McAvoy的博客 363

Codeforces-1008B - Turn the Rectangles - 水题

题解链接 https://www.lucien.ink/archives/306/ 题目链接 http://codeforces.com/contest/1008/problem/B 题目 There are nnn rectangles in a row. You can either turn each rectangle by 909090 degrees or leave...

LucienShui 782

/1008/problem/B Turn the Rectangles

B. Turn the Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn rectangles in a row. You can either turn each...

swqeaaa的博客 135

CodeForce1008B Turn the Rectangles(贪心思维)

B. Turn the Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn rectangles in a row. You can either turn each...

lanshan1111的博客 236

1008B. Turn the Rectangles(贪心)

There are n rectangles in a row. You can either turn each rectangle by 90 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that yo...

码农的一亩三分地 262

Codeforces-1008B - Turn the Rectangles - 水题-

There are nn rectangles in a row. You can either turn each rectangle by 9090 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that ...

Sean 240

Codeforces ~ 1008B ~ Turn the Rectangles(水,贪心)

题意有n个长方形,给你他的w和h,问不改变顺序,能不能通过旋转长方形(即交换w和h),使得这n个长方形的w单调非递增。题解贪心的每次使得长方形的w较大就好了。#include &lt;bits/stdc++.h&gt; using namespace std; const int INF = 0x3f3f3f3f; int n; int main() { scanf("%d", &amp;...

张松超的博客 396

CF 1008B Turn the Rectangles(水题+贪心)

There arenrectangles in a row. You can either turn each rectangle by90degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice tha...

weixin_30244681的博客 88

Codeforces Round #497 (Div. 2) B. Turn the Rectangles

B. Turn the Rectanglestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn rectangles in a row. You can either turn each rectangle by 9090...

Zeolim的博客 273
上一篇: 百毒之星资格赛A题
下一篇: C - Reorder the Array
郭晋龙
博客等级 码龄6年 940粉丝 449原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郭晋龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值