I. Intergalactic Bidding

Codeforces
IDCF10193I
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Today the Intergalactic Council of Pebble Coins (ICPC) conducted an intergalactic auction of the Neutronium Chaos Pebble Coin (NCPC). This coin, which was forged in the Ancient Coin Machine (ACM), is rumored to be the key to ruling the universe. Due to the extremely competitive nature of the auction, as well as the odd mechanics of the intergalactic currency used (far too advanced for mere mortals to understand), the auction was conducted with the following rules: After the auction there were a lot of sore losers – understandably, having just lost their chance at world domination. To make the losers feel a little better and prevent possible rioting, the ICPC has decided to hold a lottery for the participants. The winners of the lottery are determined as follows. The ICPC picks a random number $s$. A group of participants is called #cf_span(class=[tex-font-style-underline], body=[winning]) if the sum of their bets from the auction is equal to $s$. A participant wins the lottery and receives a prize – a shiny Pebble Coin – if they belong to any winning group of participants. Given the names of the participants, the bets that they made, and the random number $s$ chosen by the ICPC, help them determine which participants won the lottery. The first line of input contains two integers $n$ and $s$, where $1 <= n <= 1 thin 000$ is the number of participants, and $1 <= s < 10^(1 thin 000)$ is the random number chosen by the ICPC. Then follow $n$ lines describing the participants. Each line contains a string $t$ and an integer $b$, where $t$ is the name of a participant, and $1 <= b < 10^(1 thin 000)$ is the amount of his bet. The name of each participant is unique and consists of between $1$ and $20$ letters from the English alphabet. Output an integer $k$ denoting the number of participants that won the lottery. Then output $k$ lines containing the names of the participants that won the lottery, one per line, in any order. ## Input The first line of input contains two integers $n$ and $s$, where $1 <= n <= 1 thin 000$ is the number of participants, and $1 <= s < 10^(1 thin 000)$ is the random number chosen by the ICPC.Then follow $n$ lines describing the participants. Each line contains a string $t$ and an integer $b$, where $t$ is the name of a participant, and $1 <= b < 10^(1 thin 000)$ is the amount of his bet. The name of each participant is unique and consists of between $1$ and $20$ letters from the English alphabet. ## Output Output an integer $k$ denoting the number of participants that won the lottery. Then output $k$ lines containing the names of the participants that won the lottery, one per line, in any order. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of participants. Let $ s \in \mathbb{Z}^+ $ be the target sum. Let $ P = \{ (name_i, bet_i) \mid i \in \{1, \dots, n\} \} $ be the set of participants, where $ name_i $ is a unique string and $ bet_i \in \mathbb{Z}^+ $ is the bet amount. **Constraints** 1. $ 1 \leq n \leq 1000 $ 2. $ 1 \leq s < 10^{1000} $ 3. $ 1 \leq bet_i < 10^{1000} $ for all $ i \in \{1, \dots, n\} $ 4. Each $ name_i $ is a string of 1 to 20 English letters. **Objective** Find the set $ W \subseteq \{ name_1, \dots, name_n \} $ such that: $$ W = \left\{ name_i \mid \exists S \subseteq \{1, \dots, n\},\ \sum_{j \in S} bet_j = s \text{ and } i \in S \right\} $$ Output $ |W| $, followed by the elements of $ W $ in any order.
API Response (JSON)
{
  "problem": {
    "name": "I. Intergalactic Bidding",
    "description": {
      "content": "Today the Intergalactic Council of Pebble Coins (ICPC) conducted an intergalactic auction of the Neutronium Chaos Pebble Coin (NCPC). This coin, which was forged in the Ancient Coin Machine (ACM), is ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10193I"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Today the Intergalactic Council of Pebble Coins (ICPC) conducted an intergalactic auction of the Neutronium Chaos Pebble Coin (NCPC). This coin, which was forged in the Ancient Coin Machine (ACM), is ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of participants.  \nLet $ s \\in \\mathbb{Z}^+ $ be the target sum.  \nLet $ P = \\{ (name_i, bet_i) \\mid i \\in \\{1, \\dots, n\\} \\} $ be the set of...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments