QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22483. Automat z napojami gazowanymi

Statistics

Dla rosnących potrzeb $N$ krów ($1 \le N \le 50,000$) Farmer John kupił automat z napojami gazowanymi i szuka idealnego miejsca.

Pastwisko jest osią liczbową. Krowa $i$ pasie się w $A_i..B_i$ ($1 \le A_i \le B_i; A_i \le B_i \le 1,000,000,000$), z końcami. Automat w dowolnym całkowitym punkcie $1..1,000,000,000$. Leniwe krowy chcą mało chodzić i mieć go w swoim przedziale.

Nie zawsze wszystkie zadowolone. FJ chce największej liczby.

Cztery przedziały $3..5$, $4..8$, $1..2$, $5..10$ pokazane niżej:

         1   2   3   4   5   6   7   8   9  10  11  12  13
         |---|---|---|---|---|---|---|---|---|---|---|---|-...
                 aaaaaaaaa
                     bbbbbbbbbbbbbbbbb
         ccccc           ddddddddddddddddddddd

Pierwsza, druga, czwarta mają wspólny $5$; trzecia rozłączna. Maksimum 3 mają go w przedziale.

Wejście

  • Wiersz 1: całkowite $N$.
  • Wiersze $2..N+1$: wiersz $i+1$, dwie liczby całkowite $A_i$, $B_i$ rozdzielone spacją.

Wyjście

  • Wiersz 1: jedna liczba całkowita, maksimum krów, których przedziały mogą wszystkie zawierać automat.

Przykład

Wejście 1

4
3 5
4 8
1 2
5 10

Wyjście 1

3

Uwagi

W $5$ zadowala 1, 2, 4; wszystkich czterech nie można.

Autor zadania: Neal Wu, 2008.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.