{"problem":{"name":"Always Increasing","description":{"content":"You are given a sequence of positive integers $A=(A_1,A_2,\\ldots,A_N)$ of length $N$, and you will perform $Q$ operations on it. For $1\\leq q\\leq Q$, the $q$\\-th operation is given as positive integer","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc210_a"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence of positive integers $A=(A_1,A_2,\\ldots,A_N)$ of length $N$, and you will perform $Q$ operations on it. For $1\\leq q\\leq Q$, the $q$\\-th operation is given as positive integers $i_q, x_q$ (where $1\\leq i_q\\leq N$), and it adds $x_q$ to $A_{i_q}$.\nYour goal is to appropriately determine the initial state of $A$ so that the following condition holds at any point in time (that is, in the initial state and immediately after each operation).\n\n*   $0<A_1 < A_2 < \\cdots < A_N$ holds.\n\nWhen achieving this goal, find the minimum possible sum of elements in the initial state of $A$.\n\n## Constraints\n\n*   $2\\leq N\\leq 2\\times 10^5$\n*   $1\\leq Q\\leq 2\\times 10^5$\n*   $1\\leq i_q\\leq N$\n*   $1\\leq x_q\\leq 10^5$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $Q$\n$i_1$ $x_1$\n$\\vdots$\n$i_Q$ $x_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc210_a","tags":[],"sample_group":[["4 2\n1 2\n2 3","22\n\nSuppose the initial state of $A$ is $A=(1,4,8,9)$. Then,\n\n*   $A$ immediately after the $1$\\-st operation: $A=(3,4,8,9)$\n*   $A$ immediately after the $2$\\-nd operation: $A=(3,7,8,9)$\n\nand it can be verified that $A$ satisfies the condition at any point in time.\nIn this case, the sum of elements in the initial state of $A$ is $\\displaystyle \\sum_{i=1}^NA_i=1+4+8+9=22$."],["4 2\n2 3\n1 2","16"],["100000 1\n1 100000","14999950000"]],"created_at":"2026-03-03 11:01:14"}}