AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

BAPC23-098.Exam Study Planning

Medium · 1 s · 256 MB

  • icpc
  • bapc
  • 2023

You have a lot of exams today! And you have not yet prepared for any of them! At least you know from experience that if you study enough for an exam, you will for sure pass it quickly, well within the allotted time. Even better, you stared so long at the daunting course curricula that you now know exactly how much time you will need to study for each exam in order to pass it within the given time. If you do not study long enough, you will for sure fail it.

As it happens, your university has some weird bureaucratic rules that require you to attend all your exams. The horror! And leaving early is not allowed, unless you know for sure you passed it!

Given the full exam schedule of when each exam starts, how long each exam takes, how much time you need to study for each exam, and how quickly you can finish each exam you studied for, how many exams can you pass at most?

You may start studying at time 000, but can only study while not making an exam. The preparation for an exam does not have to be done in a contiguous block of time and may be interrupted.

Giriş formatı

The input consists of:

• One line with an integer nnn (1≤n≤20001 \leq n\leq 20001≤n≤2000), the number of exams you have to attend.

• nnn lines, the iiith of which contains four integers describing an exam:

• sis_isi​ (0≤si0 \leq s_i0≤si​), the start time of the iiith exam,

• pip_ipi​ (si<pis_i < p_isi​<pi​), the end time of the iiith exam if you prepare for it,

• eie_iei​ (pi≤ei≤109p_i \leq e_i \leq 10^9pi​≤ei​≤109), the end time of the iiith exam if you do not prepare for it,

• aia_iai​ (1≤ai≤1091 \leq a_i \leq 10^91≤ai​≤109), the time needed to prepare the iiith exam.

The exams are given in ascending order of start time, and do not overlap, i.e. ei≤si+1e_i \leq s_{i+1}ei​≤si+1​ holds for 1≤i<n1 \leq i < n1≤i<n.

Çıxış formatı

Output the maximum number of exams you can pass.

Qeyd

Source: Benelux Algorithm Programming Contest 2023 · Author: Jorke de Vlas and Reinier Schmiermann · License: CC BY-SA 4.0 · Original: https://bapc.eu · Statement adapted for AlgoLens and shared under the same license.

Nümunələr

Giriş #1

3
10 20 30 5
30 50 100 15
100 101 200 50

Çıxış #1

3

Giriş #2

3
1000 1001 1002 1000
1003 1004 1005 500
1006 1007 1008 500

Çıxış #2

2