H. String Deletion

Codeforces
IDCF10279H
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You have a string $s$ consisting of $n$ characters. Each character is either _0_ or _1_. You can perform operations on the string. Each operation consists of two steps: Note that both steps are mandatory in each operation, and their order cannot be changed. For example, if you have a string $s =$ _111010_, the first operation can be one of the following: You finish performing operations when the string $s$ becomes empty. What is the maximum number of operations you can perform? The first line contains a single integer $n$ ($1 <= n <= 2 dot.op 10^5$) — the length of the string $s$. The second line contains string $s$ of $n$ characters. Each character is either _0_ or _1_. Print a single integer — the maximum number of operations you can perform. ## Input The first line contains a single integer $n$ ($1 <= n <= 2 dot.op 10^5$) — the length of the string $s$.The second line contains string $s$ of $n$ characters. Each character is either _0_ or _1_. ## Output Print a single integer — the maximum number of operations you can perform. [samples]
**Definitions** Let $ s \in \{0,1\}^n $ be a binary string of length $ n $. Let $ c_0 $ be the number of '0's in $ s $. Let $ c_1 $ be the number of '1's in $ s $. **Constraints** $ 1 \leq n \leq 2 \cdot 10^5 $ **Objective** Maximize the number of operations, where each operation removes one '0' and one '1'. The maximum number of operations is: $$ \min(c_0, c_1) $$
API Response (JSON)
{
  "problem": {
    "name": "H. String Deletion",
    "description": {
      "content": "You have a string $s$ consisting of $n$ characters. Each character is either _0_ or _1_. You can perform operations on the string. Each operation consists of two steps: Note that both steps are mand",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10279H"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You have a string $s$ consisting of $n$ characters. Each character is either _0_ or _1_.\n\nYou can perform operations on the string. Each operation consists of two steps:\n\nNote that both steps are mand...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s \\in \\{0,1\\}^n $ be a binary string of length $ n $.  \nLet $ c_0 $ be the number of '0's in $ s $.  \nLet $ c_1 $ be the number of '1's in $ s $.  \n\n**Constraints**  \n$ 1 \\leq ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments