#P16210. [ICPC 2024 NAC]Training, Round 2

[ICPC 2024 NAC]Training, Round 2

题目描述

Ashley 正在训练下一场程序设计比赛。教练 Tom 为她准备了一列题目。每道题都有两个难度维度:

  • 实现难度范围;
  • 思维难度范围。

Ashley 当前有实现能力 ii 和思维能力 tt。她会按给定顺序依次看这些题目;对每道题,她可以选择跳过或者解决。一旦跳过某题,以后不能再回到这题。

只有当 Ashley 当前的两个能力值都落在该题对应范围内时,她才能解决这道题。解决一道题后,她必须反思训练,并且可以选择:

  • 实现能力加 11;或
  • 思维能力加 11

二者不能同时增加,也不能不增加。

请计算她在最优选择下最多能解决多少道题。

输入格式

第一行包含三个整数 n,i,tn,i,t

  • nn:题目数量;
  • ii:初始实现能力;
  • tt:初始思维能力。

接下来 nn 行,每行包含四个整数:

ilow ihigh tlow thigh

表示该题的实现难度范围为 [ilow,ihigh][ilow, ihigh],思维难度范围为 [tlow,thigh][tlow, thigh],均为闭区间。

约束:

  • 1n50001 \le n \le 5000
  • 0i,t1090 \le i,t \le 10^9
  • 0ilowihigh21090 \le ilow \le ihigh \le 2\cdot 10^9
  • 0tlowthigh21090 \le tlow \le thigh \le 2\cdot 10^9

输出格式

输出一个整数,表示 Ashley 最多可以解决的题目数量。

样例输入 #1

3 0 0
0 1 0 1
1 1 0 1
1 1 1 1

样例输出 #1

3