#K71652. Maximizing Attractions Attendance

    ID: 33579 Type: Default 1000ms 256MiB

Maximizing Attractions Attendance

Maximizing Attractions Attendance

You are given a day schedule of attractions, each with a start time and an end time. A single visitor can only attend an attraction if its start time is not earlier than the end time of the previously attended attraction. Your task is to determine the maximum number of attractions the visitor can attend in one day.

Formally, if an attraction is represented by its start time \(s_i\) and end time \(e_i\), then for any two consecutively attended attractions \(i\) and \(j\), the condition \(s_j \ge e_i\) must hold. Use a greedy algorithm approach to solve this scheduling problem.

inputFormat

The input is given in the following format via standard input (stdin):

  1. An integer \(n\) representing the number of attractions.
  2. A line with \(n\) space-separated integers representing the start times \(s_1, s_2, \dots, s_n\).
  3. A line with \(n\) space-separated integers representing the end times \(e_1, e_2, \dots, e_n\).

outputFormat

Output a single integer to standard output (stdout) representing the maximum number of attractions a visitor can attend.

## sample
6
1 3 0 5 8 5
2 4 6 7 9 9
4