#abc325b. B - World Meeting

B - World Meeting

Score : 250250 points

问题描述

Keyence在全球拥有NN个基地,编号从11NN。第ii个基地有WiW_i名员工,在协调世界时(UTC)的0点,基地ii的时间为XiX_i点。

你希望在整个公司范围内召开一场一小时的会议。每位员工只有在其所在基地的9:00-18:00时间段内完全包含会议时间时才能参加会议。请确定会议时间,使得尽可能多的员工能够参加,并找出最多能有多少名员工参加会议。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Keyence has NN bases worldwide, numbered 11 to NN. Base ii has WiW_i employees, and at 00 o'clock in Coordinated Universal Time (UTC), it is XiX_i o'clock at base ii.

You want to hold a one-hour meeting across the entire company. Each employee can only participate in the meeting if the meeting time is completely within the 9:00-18:00 time slot at their base. Find the maximum number of employees who can participate when deciding the meeting time to allow as many employees as possible to participate.

Constraints

  • 1N10001\leq N \leq 1000
  • 1Wi1061\leq W_i \leq 10^6
  • 0Xi<240\leq X_i < 24
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

W1W_1 X1X_1

W2W_2 X2X_2

\vdots

WNW_N XNX_N

Output

Print the maximum number of employees who can participate in the meeting.

Sample Input 1

3
5 0
3 3
2 18

Sample Output 1

8

Consider holding the meeting from 14:00 to 15:00 in UTC.

  • The meeting is held from 14:00 to 15:00 at base 11, so the 55 employees at base 11 can participate in the meeting.
  • The meeting is held from 17:00 to 18:00 at base 22, so the 33 employees at base 22 can participate in the meeting.
  • The meeting is held from 8:00 to 9:00 at base 33, so the 22 employees at base 33 cannot participate in the meeting.

Thus, a total of 5+3=85+3=8 employees can participate in the meeting. No meeting time allows more employees to participate.

Sample Input 2

2
1 10
1000000 20

Sample Output 2

1000000

Sample Input 3

6
31 3
20 8
11 5
4 3
47 14
1 18

Sample Output 3

67

update @ 2024/3/10 01:47:32