306035: CF1136A. Nastya Is Reading a Book

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Nastya Is Reading a Book

题意翻译

## 题目描述 Nastya决定读一本有 $n$ 个章节的书。这本书的每一页都属于一章中,同样的,每一章至少有 $1$ 页。 昨晚 Nastya 没有看完书, 所以她在第 $k$ 页做下了记号,第 $k$ 页就是还没有读的第 $1$ 页(换句话说,她读了从第 $1$ 页到第 $\left(k-1\right)$ 页。 第二天, Nastya 的朋友 Igor 来问她,还有多少章没读。 但是 Nastya 太忙了, 所以让你来求出她还有多少章节**没完全读完**。 ## 输入格式 第 $1$ 行包含一个整数 $n\left(1\le n\le 100\right)$,表示这本书的章节数。 第 $2$ 行到第 $n+1$ 行,每行包括两个整数 $l_i$ 和 $r_i$,$\left(l_1=1\; ,l_i\le r_i\;,1\le i \le n-1\right)$ 表示第 $i$ 章的起止页码,每章节最多包含 $100$ 页。 第 $n+2$ 行包含一个整数 $k$ $\left(1\le k \le r_n\right)$,表示做标记的页码。 ## 输出格式 输出一个整数,表示没有完全读完的章节数。

题目描述

After lessons Nastya decided to read a book. The book contains $ n $ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number $ k $ as the first page which was not read (i.e. she read all pages from the $ 1 $ -st to the $ (k-1) $ -th). The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 1 \leq n \leq 100 $ ) — the number of chapters in the book. There are $ n $ lines then. The $ i $ -th of these lines contains two integers $ l_i $ , $ r_i $ separated by space ( $ l_1 = 1 $ , $ l_i \leq r_i $ ) — numbers of the first and the last pages of the $ i $ -th chapter. It's guaranteed that $ l_{i+1} = r_i + 1 $ for all $ 1 \leq i \leq n-1 $ , and also that every chapter contains at most $ 100 $ pages. The $ (n+2) $ -th line contains a single integer $ k $ ( $ 1 \leq k \leq r_n $ ) — the index of the marked page.

输出格式


Print a single integer — the number of chapters which has not been completely read so far.

输入输出样例

输入样例 #1

3
1 3
4 7
8 11
2

输出样例 #1

3

输入样例 #2

3
1 4
5 9
10 12
9

输出样例 #2

2

输入样例 #3

1
1 7
4

输出样例 #3

1

说明

In the first example the book contains $ 11 $ pages and $ 3 $ chapters — $ [1;3] $ , $ [4;7] $ and $ [8;11] $ . Nastya marked the $ 2 $ -nd page, so she finished in the middle of the $ 1 $ -st chapter. So, all chapters has not been read so far, so the answer is $ 3 $ . The book in the second example contains $ 12 $ pages and $ 3 $ chapters too, but Nastya finished reading in the middle of the $ 2 $ -nd chapter, so that the answer is $ 2 $ .

Input

题意翻译

## 题目描述 Nastya决定读一本有 $n$ 个章节的书。这本书的每一页都属于一章中,同样的,每一章至少有 $1$ 页。 昨晚 Nastya 没有看完书, 所以她在第 $k$ 页做下了记号,第 $k$ 页就是还没有读的第 $1$ 页(换句话说,她读了从第 $1$ 页到第 $\left(k-1\right)$ 页。 第二天, Nastya 的朋友 Igor 来问她,还有多少章没读。 但是 Nastya 太忙了, 所以让你来求出她还有多少章节**没完全读完**。 ## 输入格式 第 $1$ 行包含一个整数 $n\left(1\le n\le 100\right)$,表示这本书的章节数。 第 $2$ 行到第 $n+1$ 行,每行包括两个整数 $l_i$ 和 $r_i$,$\left(l_1=1\; ,l_i\le r_i\;,1\le i \le n-1\right)$ 表示第 $i$ 章的起止页码,每章节最多包含 $100$ 页。 第 $n+2$ 行包含一个整数 $k$ $\left(1\le k \le r_n\right)$,表示做标记的页码。 ## 输出格式 输出一个整数,表示没有完全读完的章节数。

加入题单

上一题 下一题 算法标签: