Programming Problem Statements
Programming Problem Statements
1. Synergistic Scrolls
In the mystical Kingdom of Learnaria, the revered Library of Infinite Knowledge houses n ancient
- Arcane Insights (ai) - cherished by the Grand Archivists for their profound intellectual value.
- Practical Applications (bi) - favored by the People of Learnaria for their real-world utility.
The King has decreed that the total number of synergistic pairs in the library must be determined.
Input Format:
1. The first line contains an integer n (2 <= n <= 2 x 10^5) - the number of scrolls.
2. The second line contains n integers a1, a2, ..., an (1 <= ai <= 10^9) representing Arcane Insights.
3. The third line contains n integers b1, b2, ..., bn (1 <= bi <= 10^9) representing Practical
Applications.
Output Format:
paths. Each chamber contains some amount of treasure. Dora aims to maximize the treasure
Input Format:
1. The first line contains two integers n and m (1 <= n <= 10^5, 1 <= m <= 2 x 10^5).
2. The second line contains n integers where the i-th integer ti (1 <= ti <= 10^9) represents the
treasure in chamber i.
3. Each of the next m lines describes a unidirectional connection: u and v (1 <= u, v <= n).
Output Format:
In a world of islands and bridges, Pari and Averi want to meet. They aim to minimize their total travel
distance to reach two islands P and Q, such that there exists at least one bridge connecting P and
Q.
Input Format:
1. The first line contains two integers n and m (2 <= n <= 10^5, 1 <= m <= 10^5) - the number of
2. The second line contains two integers A and B - the islands where Pari and Averi are currently
located (A != B).
3. The next m lines describe the bridges: u, v, w, where u connects to v with a distance w (1 <= u, v
Output Format:
Luna and Elio want to maximize their treasure collection by exploring two non-overlapping subarrays
of a sequence T.
Input Format:
1. The first line contains an integer n (2 <= n <= 10^5) - the number of chambers.
2. The second line contains n integers T[1], T[2], ..., T[n] (|T[i]| <= 10^9) representing the treasure in
each chamber.
Output Format:
The maximum total treasure Luna and Elio can collect. If no valid configuration exists, print -1.
5. Chocolate Sharing
Brenda shares chocolates from N batches equally between herself and Rosie. She always picks two
Input Format:
1. The first line contains N (2 <= N <= 10^8) - the number of batches.
Output Format:
An integer representing the maximum number of times Brenda can share chocolates equally.
Pari and Averi want to minimize the total travel distance from their current islands A and B to meet at
Input Format:
1. The first line contains two integers n and m (2 <= n <= 10^5, 1 <= m <= 10^5) - the number of
2. The second line contains two integers A and B (A != B) - the initial islands of Pari and Averi.
3. The next m lines describe the bridges: u, v, w, where u connects to v with a weight w (1 <= u, v