Skip to content

Commit 97c6f46

Browse files
authored
Create q002.md for Accumulator Apex problem
Added problem statement and details for 'Accumulator Apex'.
1 parent a6b7df9 commit 97c6f46

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

  • Problems/Data-structures/Day-04
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# 🧮 Accumulator Apex
2+
3+
**Problem Link:**
4+
🔗 https://codeforces.com/problemset/problem/1912/A
5+
6+
**Time Limit:** 3 seconds
7+
**Memory Limit:** 1024 MB
8+
9+
---
10+
11+
## 📘 Problem Statement
12+
13+
Allyn is playing a new strategy game called **Accumulator Apex**.
14+
15+
In this game:
16+
17+
- Allyn is given an initial integer value **x**, called the **accumulator**.
18+
- There are **k** lists of integers.
19+
- Allyn can make multiple turns.
20+
21+
### 🔁 Game Rules
22+
23+
On each turn, Allyn can:
24+
25+
- Choose **any non-empty list**
26+
- Withdraw the **leftmost element** from that list
27+
- Add it to the accumulator **x**, **only if** the resulting value of **x** is **non-negative**
28+
29+
Allyn may **end the game at any moment**.
30+
31+
---
32+
33+
## 🎯 Objective
34+
35+
Find the **maximum possible value** of the accumulator **x** that Allyn can achieve.
36+
37+
---
38+
39+
### 📥 Input Format
40+
41+
The first line contains two integers **x** and **k**:
42+
43+
- $0 \le x \le 10^9$
44+
- $1 \le k \le 10^5$
45+
46+
The next **k** lines describe the lists:
47+
48+
- Each line starts with an integer **lᵢ** $(lᵢ \ge 1)$
49+
- Followed by **lᵢ** integers representing the list elements (from left to right)
50+
51+
---
52+
53+
### 🔢 Constraints
54+
55+
- Each element in the lists satisfies:
56+
$|a_{ij}| \le 10^9$
57+
58+
- The total number of elements across all lists does not exceed:
59+
$10^5$
60+
61+
---
62+
63+
## 📤 Output Format
64+
65+
- Print a single integer — the **maximum possible value** of the accumulator **x**.
66+
67+
---
68+
69+
## 📝 Notes
70+
71+
- Elements must be taken **from the left end** of a list.
72+
- You can switch between lists at any time.
73+
- You are **not required** to consume all elements.
74+
- The accumulator value must **never become negative**.
75+
76+
---
77+
78+
## ✅ Example (Conceptual)
79+
80+
If at some point adding an element makes the accumulator negative, that move is **not allowed**.
81+
82+
The optimal strategy may involve:
83+
- Taking positive elements early
84+
- Skipping lists that block progress due to large negative prefixes
85+
86+
---
87+
88+
## 🏁 End of Problem

0 commit comments

Comments
 (0)