{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003ch2\u003eProblem I:\n\n\u003c/h2\u003e\n\n\u003cp\u003e\n There are two countries, Imperial Cacao and Principality of Cocoa. Two girls, Alice (the Empress of Cacao) and Brianna (the Princess of Cocoa) are friends and both of them love chocolate very much.\n\u003c/p\u003e\n\n\u003cp\u003e\nOne day, Alice found a transparent tube filled with chocolate balls (Figure I.1). The tube has only one opening at its top end. The tube is narrow, and the chocolate balls are put in a line. Chocolate balls are identified by integers 1, 2, . . ., $N$ where $N$ is the number of chocolate balls. Chocolate ball 1 is at the top and is next to the opening of the tube. Chocolate ball 2 is next to chocolate ball 1, . . ., and chocolate ball $N$ is at the bottom end of the tube. The chocolate balls can be only taken out from the opening, and therefore the chocolate balls must be taken out in the increasing order of their numbers.\n\u003c/p\u003e\n\n\u003ccenter\u003e\n\u003cimg src\u003d\"CDN_BASE_URL/f8405148c1d547a6eeae8edb4f64a770?v\u003d1715283910\" width\u003d\"360\"\u003e\u003cbr\u003e\n\u003cp\u003eFigure I.1. Transparent tube filled with chocolate balls\u003c/p\u003e\n\u003c/center\u003e\n\n\u003cp\u003e\nAlice visited Brianna to share the tube and eat the chocolate balls together. They looked at the chocolate balls carefully, and estimated that the $nutrition value$ and the $deliciousness$ of chocolate ball $i$ are $r_i$ and $s_i$, respectively. Here, each of the girls wants to maximize the sum of the deliciousness of chocolate balls that she would eat. They are sufficiently wise to resolve this\nconflict peacefully, so they have decided to play a game, and eat the chocolate balls according to the rule of the game as follows:\n\u003c/p\u003e\n\n\u003col\u003e\n\u003cli\u003e Alice and Brianna have initial energy levels, denoted by nonnegative integers $A$ and $B$, respectively.\u003c/li\u003e\n\u003cli\u003e Alice and Brianna takes one of the following two actions in turn:\n \u003cul\u003e\n \u003cli\u003e \u003cb\u003ePass\u003c/b\u003e: she does not eat any chocolate balls. She gets a little hungry $-$ specifically, her energy level is decreased by 1. She cannot pass when her energy level is 0.\u003c/li\u003e\n\n \u003cli\u003e\u003cb\u003eEat\u003c/b\u003e: she eats the topmost chocolate ball $-$ let this chocolate ball $i$ (that is, the chocolate ball with the smallest number at that time). Her energy level is increased by $r_i$, the nutrition value of chocolate ball $i$ (and NOT decreased by 1). Of course, chocolate ball $i$ is removed from the tube.\n \u003c/li\u003e\n \u003c/ul\u003e\n\u003c/li\u003e\u003cli\u003e Alice takes her turn first.\u003c/li\u003e\n\u003cli\u003e The game ends when all chocolate balls are eaten.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003cp\u003e\n You are a member of the staff serving for Empress Alice. Your task is to calculate the sums of deliciousness that each of Alice and Brianna can gain, when both of them play optimally.\n\u003c/p\u003e\n\n\n\u003ch3\u003eInput\u003c/h3\u003e\n\n\u003cp\u003e\nThe input consists of a single test case. The test case is formatted as follows.\n \u003cbr\u003e\n \u003cbr\u003e\n\n$N$ $A$ $B$\u003cbr\u003e\n$r_1$ $s_1$\u003cbr\u003e\n$r_2$ $s_2$\u003cbr\u003e\n.\u003cbr\u003e\n.\u003cbr\u003e\n.\u003cbr\u003e\n$r_N$ $s_N$\u003cbr\u003e\u003cbr\u003e\n\n The first line contains three integers, $N$, $A$ and $B$. $N$ represents the number of chocolate balls. $A$ and $B$ represent the initial energy levels of Alice and Brianna, respectively. The following $N$ lines describe the chocolate balls in the tube. The chocolate balls are numbered from 1 to $N$, and each of the lines contains two integers, $r_i$ and $s_i$ for $1 \\leq i \\leq N$. $r_i$ and $s_i$ represent the nutrition value and the deliciousness of chocolate ball $i$, respectively. The input satisfies\n\u003c/p\u003e\n\n\u003cul\u003e\n\u003cli\u003e $1 \\leq N \\leq 150$,\u003c/li\u003e\n\u003cli\u003e $0 \\leq A, B, r_i \\leq 10^9$,\u003c/li\u003e\n\u003cli\u003e $0 \\leq s_i$, and\u003c/li\u003e\n\u003cli\u003e $\\sum^N_{i\u003d1} s_i \\leq 150$\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n\n\u003cp\u003e\nOutput two integers that represent the total deliciousness that Alice and Brianna can obtain when they play optimally\n\u003c/p\u003e\n\n\n\n\u003ch3\u003eSample Input 1\u003c/h3\u003e\n\n\u003cpre\u003e2 5 4\n5 7\n4 8\u003c/pre\u003e\n\n\u003ch3\u003eSample Output 1\u003c/h3\u003e\n\n\u003cpre\u003e8 7\u003c/pre\u003e\n\n\u003ch3\u003eSample Input 2\u003c/h3\u003e\n\n\u003cpre\u003e3 50 1\n49 1\n0 10\n0 1\u003c/pre\u003e\n\n\u003ch3\u003eSample Output 2\u003c/h3\u003e\n\n\u003cpre\u003e10 2\u003c/pre\u003e\n\n\u003ch3\u003eSample Input 3\u003c/h3\u003e\n\n\u003cpre\u003e4 3 2\n1 5\n2 46\n92 40\n1 31\u003c/pre\u003e\n\n\u003ch3\u003eSample Output 3\u003c/h3\u003e\n\n\u003cpre\u003e77 45\u003c/pre\u003e\n\n\u003ch3\u003eSample Input 4\u003c/h3\u003e\n\n\u003cpre\u003e5 2 5\n56 2\n22 73\n2 2\n1 55\n14 18\u003c/pre\u003e\n\n\u003ch3\u003eSample Output 4\u003c/h3\u003e\n\n\u003cpre\u003e57 93\u003c/pre\u003e\n"}}]}