#P16789. [蓝桥杯 2026 国 A] 核心任务调度

    ID: 19130 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>贪心堆2026蓝桥杯国赛反悔贪心

[蓝桥杯 2026 国 A] 核心任务调度

Problem Description

Xiao Lan is a project manager at a company and needs to handle a large number of tasks every day. Now the company has a total of NN tasks to complete, and each task takes one day.

Days start from day 11 and are numbered by positive integers as day 11, day 22, day 33, and so on. Xiao Lan can complete at most one task per day, and may also leave a day with no task scheduled.

Each task has a deadline tt and a value ww. If the task is completed on day tt or earlier, it can create value ww for the company; if it exceeds the deadline, the task becomes invalid and can no longer be completed.

Among these tasks, some are marked as core tasks. The company requires that when Xiao Lan makes a schedule, they must first maximize the number of completed core tasks; among all schedules that satisfy this, they should then maximize the total value of all completed tasks.

Now, please help Xiao Lan compute: the maximum number of core tasks that can be completed, and under the condition that the number of completed core tasks is maximized, the maximum total value that can be obtained.

Input Format

The first line contains a positive integer NN, indicating the total number of tasks.

The next NN lines each contain three integers ti,wi,is_keyit_i, w_i, \text{is\_key}_i, representing the deadline, value, and whether the ii-th task is a core task, respectively.

Here, is_keyi=1\text{is\_key}_i = 1 means it is a core task, and is_keyi=0\text{is\_key}_i = 0 means it is a normal task.

Output Format

Output one line containing two integers, representing the maximum number of core tasks that can be completed, and under this condition, the maximum total value that can be obtained.

4
3 10 1
1 5 1
2 100 0
1 100 0
2 115

Hint

Sample Explanation

To prioritize completing as many core tasks as possible, Xiao Lan can schedule task 22 on day 11 and task 11 on day 33. In this way, they can complete 22 core tasks, with a total value of 1515.

While keeping the completion of 22 core tasks, they can also schedule task 33 on day 22, making the total value 5+100+10=1155 + 100 + 10 = 115. The deadline of task 44 is day 11, and it can no longer be completed on time.

Constraints and Notes for Test Cases

For 30%30\% of the test cases, 1≤N≤10001 \le N \le 1000, 1≤ti≤10001 \le t_i \le 1000.

For all test cases, 1≤N≤2×1051 \le N \le 2 \times 10^5, 1≤ti≤1091 \le t_i \le 10^9, 1≤wi≤1091 \le w_i \le 10^9.

Translated by ChatGPT 5