304530: CF863E. Turn Off The TV

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

Description

Turn Off The TV

题意翻译

题意: Luba有n台电视,并且她知道每台电视的工作时间是从l到r.现在Luba想要关掉一些电视,使得播放电视节目的时间点不少于关掉这些电视之前.请你帮助Luba,告诉她可以关闭哪些电视,若任何一台都不能关闭,输出-1 输入: 第一行一个整数n(1<=n<=200000),表示电视台的数量 接下来n行每行两个整数li,ri,表示第i台电视工作的时间(0<=li,ri<=10^9) 输出: 若不能关闭任何一台电视,输出-1,否则,输出任何一台可以关闭的电视的编号(编号在1~n之间) 感谢@凌幽 提供的翻译

题目描述

Luba needs your help again! Luba has $ n $ TV sets. She knows that $ i $ -th TV set will be working from moment of time $ l_{i} $ till moment $ r_{i} $ , inclusive. Luba wants to switch off one of TV sets in order to free the socket. Let's call some TV set redundant if after switching it off the number of integer moments of time when at least one of TV sets is working won't decrease. Luba will be very upset if she has to switch off a non-redundant TV set. Help Luba by telling her the index of some redundant TV set. If there is no any, print -1.

输入输出格式

输入格式


The first line contains one integer number $ n (1<=n<=2·10^{5}) $ — the number of TV sets. Then $ n $ lines follow, each of them containing two integer numbers $ l_{i},r_{i} (0<=l_{i}<=r_{i}<=10^{9}) $ denoting the working time of $ i $ -th TV set.

输出格式


If there is no any redundant TV set, print -1. Otherwise print the index of any redundant TV set (TV sets are indexed from 1 to $ n $ ). If there are multiple answers, print any of them.

输入输出样例

输入样例 #1

3
1 3
4 6
1 7

输出样例 #1

1

输入样例 #2

2
0 10
0 10

输出样例 #2

1

输入样例 #3

3
1 2
3 4
6 8

输出样例 #3

-1

输入样例 #4

3
1 2
2 3
3 4

输出样例 #4

2

说明

Consider the first sample. Initially all integer moments of time such that at least one TV set is working are from the segment $ [1;7] $ . It's easy to see that this segment won't change if we switch off the first TV set (or the second one). Note that in the fourth sample you can switch off the second TV set, since even without it all integer moments such that any of the TV sets is working denote the segment $ [1;4] $ .

Input

题意翻译

Luba 有 $n$ 台电视,并且她知道每台电视的工作时间是从 $l$ 到 $r$。现在 Luba 想要关掉一些电视,使得播放电视节目的时间点不少于关掉这些电视之前。请你帮助 Luba,告诉她可以关闭哪些电视,若任何一台都不能关闭,输出 `-1`。 ### 输入格式: 第一行一个整数 $n$($1\le n\le 200000$),表示电视台的数量。 接下来 $n$ 行每行两个整数 $l_i,r_i$($0\leq l_i \leq r_i\leq 10 ^ 9$),表示第 $i$ 台电视工作的时间。 ### 输出格式: 若不能关闭任何一台电视,输出 `-1`,否则,输出任何一台可以关闭的电视的编号(编号在 $1\sim n$ 之间)。 感谢 @[凌幽](/user/36080) 提供的翻译。 fixed by 月。

加入题单

上一题 下一题 算法标签: