Problem E

Statement
Copy Copied
Description:
After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working for and started to sell souvenirs at the market.

This morning, as usual, Petya will come to the market. Petya has n different souvenirs to sell; ith souvenir is characterised by its weight wi and cost ci. Petya knows that he might not be able to carry all the souvenirs to the market. So Petya wants to choose a subset of souvenirs such that its total weight is not greater than m, and total cost is maximum possible.

Help Petya to determine maximum possible total cost.

Input Format:
The first line contains two integers n and m (1 ≤ n ≤ 100000, 1 ≤ m ≤ 300000) — the number of Petya's souvenirs and total weight that he can carry to the market.

Then n lines follow. ith line contains two integers wi and ci (1 ≤ wi ≤ 3, 1 ≤ ci ≤ 109) — the weight and the cost of ith souvenir.

Output Format:
Print one number — maximum possible total cost of souvenirs that Petya can carry to the market.

Note:
None

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
4668 cpp 0 2026-02-28T10:13:09.809555Z View View View Retry
4667 cpp 1 2026-02-28T10:11:57.042675Z View View View Retry
4666 cpp 1 2026-02-28T10:07:02.831681Z View View View Retry
4665 cpp 1 2026-02-28T09:56:57.899714Z View View View Retry
4664 cpp 1 2026-02-28T09:56:57.057612Z View View View Retry
4663 cpp 1 2026-02-28T09:43:44.851137Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
1169 20260227-135649 openrouter x-ai/grok-4 go false 2026-02-27T19:56:03.381362Z View View View View Retry
425 20260214-083437 openrouter moonshotai/kimi-k2.5 go true 2026-02-14T16:53:39.416707Z View View View View Retry