{"problem":{"name":"B. Level Up","description":{"content":"Being a fan of MMORPGs, Steve was really excited when World of Warcraft Classic was announced. He started playing from the first day and now has only two levels to go till the maximum level. Of course","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10239B"},"statements":[{"statement_type":"Markdown","content":"Being a fan of MMORPGs, Steve was really excited when World of Warcraft Classic was announced. He started playing from the first day and now has only two levels to go till the maximum level. Of course, he doesn't have as much time as he used to have when the game first appeared, so he really wants to finish these two levels as fast as possible.\n\nIn order to pass the first level, Steve needs $s_1$ experience. Only after he gains it, he can move to the second level, in which he needs to get other $s_2$ experience to pass it.\n\nSteve has the list of $n$ available quests. He knows that he may finish two levels with these quests. In order to pass the $i$-th quest, Steve needs $t_i$ minutes. As a result, he will get $x_i$ experience for this quest. \n\nWhen Steve finishes a quest that takes him to the next level, the extra experience overflow is subtracted from the next level's required experience. Once he levels up, all the quests that are left will offer less experience $y_i$, but they will also require less time $r_i$. \n\nNote that if Steve finishes a quest, he *can't* repeat this quest anymore (even in another level).\n\nGiven the list of quests, help Steve choose the order in which he will be doing the quests in order to finish the last two levels as fast as possible.\n\nThe first line contains three integers $n$, $s_1$, $s_2$ ($1 <= n, s_1, s_2 <= 500$) — the number of quests, experience required for the first level and experience required for the second level.\n\nEach of the next $n$ lines contains four integers $x_i$, $t_i$, $y_i$, $r_i$ ($1 <= y_i < x_i <= 500$, $1 <= r_i < t_i <= 10^9$) where $x_i$ and $y_i$ are the experience you will gain from the $i$-th quest on the $1$-st and $2$-nd level respectively and $t_i$ and $r_i$ are the number of minutes you need to spend in order to pass this quest on the $1$-st and $2$-nd level respectively,\n\nPrint one number, representing the minimum number of minutes that Steve needs to finish two levels, or $-1$ if there is no way to complete quests to finish both levels.\n\n## Input\n\nThe first line contains three integers $n$, $s_1$, $s_2$ ($1 <= n, s_1, s_2 <= 500$) — the number of quests, experience required for the first level and experience required for the second level.Each of the next $n$ lines contains four integers $x_i$, $t_i$, $y_i$, $r_i$ ($1 <= y_i < x_i <= 500$, $1 <= r_i < t_i <= 10^9$) where $x_i$ and $y_i$ are the experience you will gain from the $i$-th quest on the $1$-st and $2$-nd level respectively and $t_i$ and $r_i$ are the number of minutes you need to spend in order to pass this quest on the $1$-st and $2$-nd level respectively,\n\n## Output\n\nPrint one number, representing the minimum number of minutes that Steve needs to finish two levels, or $-1$ if there is no way to complete quests to finish both levels.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the area of the rectangle, with $ 1 \\leq n \\leq 200 $.\n\n**Objective**  \nFind integers $ h, w \\in \\mathbb{Z} $ such that:  \n$$ h \\cdot w = n $$  \nOutput any such pair $ (h, w) $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10239B","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}