CF1136A.Nastya Is Reading a Book

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

After lessons Nastya decided to read a book. The book contains nn 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 kk as the first page which was not read (i.e. she read all pages from the 11-st to the (k−1)(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).

课后,娜斯佳决定读一本书。这本书包含 nn 章,按顺序连续排列,使得书中的每一页恰好属于其中一章,且每一章至少包含一页。

昨天晚上,娜斯佳未能读完这本书,因此她将页码为 kk 的那一页标记为尚未阅读的第一页(即她已读完了从第 11 页到第 (k−1)(k-1) 页的所有页面)。

第二天,娜斯佳的朋友伊戈尔来问她:娜斯佳还有多少章尚未读完?娜斯佳现在太忙了,因此请你帮她计算她尚未完整读完的章节数量(即:她尚未开始阅读,或仅读到某一章中间就停止了的章节数量)。

输入格式

The first line contains a single integer nn (1≤n≤1001 \leq n \leq 100) — the number of chapters in the book.

There are nn lines then. The ii-th of these lines contains two integers lil_i, rir_i separated by space (l1=1l_1 = 1, li≤ril_i \leq r_i) — numbers of the first and the last pages of the ii-th chapter. It's guaranteed that li+1=ri+1l_{i+1} = r_i + 1 for all 1≤i≤n−11 \leq i \leq n-1, and also that every chapter contains at most 100100 pages.

The (n+2)(n+2)-th line contains a single integer kk (1≤k≤rn1 \leq k \leq r_n) — the index of the marked page.

第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)—— 表示书中章节数。

接下来有 nn 行。其中第 ii 行包含两个由空格分隔的整数 lil_i 和 rir_i(l1=1l_1 = 1,li≤ril_i \leq r_i)—— 分别表示第 ii 章的起始页码和结束页码。题目保证对所有 1≤i≤n−11 \leq i \leq n-1 均有 li+1=ri+1l_{i+1} = r_i + 1,且每章至多包含 100100 页。

第 (n+2)(n+2) 行包含一个整数 kk(1≤k≤rn1 \leq k \leq r_n)—— 表示被标记页码的编号。

输出格式

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 1111 pages and 33 chapters — [1;3][1;3], [4;7][4;7] and [8;11][8;11]. Nastya marked the 22-nd page, so she finished in the middle of the 11-st chapter. So, all chapters has not been read so far, so the answer is 33.

The book in the second example contains 1212 pages and 33 chapters too, but Nastya finished reading in the middle of the 22-nd chapter, so that the answer is 22.

在第一个例子中,这本书共有 1111 页和 33 章——分别为 [1;3][1;3]、[4;7][4;7] 和 [8;11][8;11]。娜斯佳标记了第 22 页,因此她停在了第 11 章的中间。所以,截至目前所有章节都尚未读完,答案为 33。

第二个例子中的书也包含 1212 页和 33 章,但娜斯佳停在了第 22 章的中间,因此答案为 22。

输入解题思路,AI测评打分。不知道怎么写?

首页