F. Forests in Danger

Codeforces
IDCF10234F
Time3000ms
Memory256MB
Difficulty
English · Original
Formal · Original
The complete problemset is available on http://maratona.ime.usp.br/primfase19/provas/competicao/maratona_en.pdf [samples]
**Definitions** Let $ n \in \mathbb{Z} $ be the length of the sequence. Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of integers, where $ a_i \in \mathbb{Z} $ for all $ i \in \{1, \dots, n\} $. A *subsegment* is defined as a contiguous subsequence $ (a_i, a_{i+1}, \dots, a_j) $ for $ 1 \leq i \leq j \leq n $. Let $ P(i,j) = \prod_{k=i}^{j} a_k $ denote the product of the subsegment from index $ i $ to $ j $. **Constraints** 1. $ 1 \leq n \leq 2 \cdot 10^5 $ 2. $ -10^9 \leq a_i \leq 10^9 $ for all $ i \in \{1, \dots, n\} $ **Objective** Compute the following three values: - $ N_{\text{neg}} = \left| \left\{ (i,j) \mid 1 \leq i \leq j \leq n,\ P(i,j) < 0 \right\} \right| $ - $ N_{\text{zero}} = \left| \left\{ (i,j) \mid 1 \leq i \leq j \leq n,\ P(i,j) = 0 \right\} \right| $ - $ N_{\text{pos}} = \left| \left\{ (i,j) \mid 1 \leq i \leq j \leq n,\ P(i,j) > 0 \right\} \right| $ Output: $ N_{\text{neg}},\ N_{\text{zero}},\ N_{\text{pos}} $
API Response (JSON)
{
  "problem": {
    "name": "F. Forests in Danger",
    "description": {
      "content": "The complete problemset is available on http://maratona.ime.usp.br/primfase19/provas/competicao/maratona_en.pdf ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10234F"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The complete problemset is available on http://maratona.ime.usp.br/primfase19/provas/competicao/maratona_en.pdf\n\n[samples]...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the length of the sequence.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of integers, where $ a_i \\in \\mathbb{Z} $ for all $ i \\in \\{1, \\dots, n\\} $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments