{"problem":{"name":"All-you-can-eat","description":{"content":"Takahashi is at an all-you-can-eat restaurant. The restaurant offers $N$ kinds of dishes. It takes $A_i$ minutes to eat the $i$\\-th dish, whose deliciousness is $B_i$. The restaurant has the following","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc145_e"},"statements":[{"statement_type":"Markdown","content":"Takahashi is at an all-you-can-eat restaurant.\nThe restaurant offers $N$ kinds of dishes. It takes $A_i$ minutes to eat the $i$\\-th dish, whose deliciousness is $B_i$.\nThe restaurant has the following rules:\n\n*   You can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n*   You cannot order the same kind of dish more than once.\n*   Until you finish eating the dish already served, you cannot order a new dish.\n*   After $T-0.5$ minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\nWhat is the maximum possible happiness achieved by making optimal choices?\n\n## Constraints\n\n*   $2 \\leq N \\leq 3000$\n*   $1 \\leq T \\leq 3000$\n*   $1 \\leq A_i \\leq 3000$\n*   $1 \\leq B_i \\leq 3000$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $T$\n$A_1$ $B_1$\n$:$\n$A_N$ $B_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc145_e","tags":[],"sample_group":[["2 60\n10 10\n100 100","110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be $110$.\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it."],["3 60\n10 10\n10 20\n10 30","60\n\nTakahashi can eat all the dishes within $60$ minutes."],["3 60\n30 10\n30 20\n30 30","50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be $50$.\nWe cannot order three dishes, in whatever order we place them."],["10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25","145"]],"created_at":"2026-03-03 11:01:14"}}