L. Basketball

Codeforces
IDCF10074L
Time2000ms
Memory64MB
Difficulty
English · Original
Formal · Original
The most important part of playing basketball in the yard is to choose two equally strong teams. Otherwise, the game could be ruined because the stronger team could win easily. However, sometimes the number of players in the team is not so important. Especially, if tall guys are playing with small kids. There are two teams: Reds and Blues. For each player in the teams we know his skills. We are interested in how many ways we can choose some players from Reds and some players from Blues, so that the created teams are equally strong. The strength of the team is the sum of the skills of its individual players. The first line of each test case contains the number of players in Reds n and the number of players in Blues m (1 ≤ n, m) (n + m ≤ 17). The second line of each test case contains the skills of players in Reds from 1 through n. The third line of each test case contains the skills of players in Blues from 1 through m. Skills are integers in the interval [1;100000000]. Output the number of ways of choosing two equally strong teams. ## Input The first line of each test case contains the number of players in Reds n and the number of players in Blues m (1 ≤ n, m) (n + m ≤ 17).The second line of each test case contains the skills of players in Reds from 1 through n.The third line of each test case contains the skills of players in Blues from 1 through m.Skills are integers in the interval [1;100000000]. ## Output Output the number of ways of choosing two equally strong teams. [samples]
**Definitions** Let $ n, m \in \mathbb{Z}^+ $ denote the number of players in Reds and Blues, respectively. Let $ R = (r_1, r_2, \dots, r_n) \in \mathbb{Z}^n $ be the skill values of Reds players. Let $ B = (b_1, b_2, \dots, b_m) \in \mathbb{Z}^m $ be the skill values of Blues players. **Constraints** 1. $ 1 \leq n, m $ and $ n + m \leq 17 $ 2. $ 1 \leq r_i, b_j \leq 10^8 $ for all $ i \in \{1,\dots,n\}, j \in \{1,\dots,m\} $ **Objective** Count the number of pairs of subsets $ (S \subseteq R, T \subseteq B) $, where $ S \neq \emptyset $ or $ T \neq \emptyset $, such that: $$ \sum_{r_i \in S} r_i = \sum_{b_j \in T} b_j $$
API Response (JSON)
{
  "problem": {
    "name": "L. Basketball",
    "description": {
      "content": "The most important part of playing basketball in the yard is to choose two equally strong teams. Otherwise, the game could be ruined because the stronger team could win easily. However, sometimes the",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10074L"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The most important part of playing basketball in the yard is to choose two equally strong teams. Otherwise, the game could be ruined because the stronger team could win easily.\n\nHowever, sometimes the...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ denote the number of players in Reds and Blues, respectively.  \nLet $ R = (r_1, r_2, \\dots, r_n) \\in \\mathbb{Z}^n $ be the skill values of Reds players....",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments