generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d93ac76
commit 5407efc
Showing
10 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Consider two arrays, a and b, both of length n. | ||
|
||
Your task is to merge these arrays into another array, c, of length 2n. Your objective is to determine the maximum length of a subarray within c that consists of the same values. | ||
|
||
A merge of two arrays results in an array c composed by successively taking the first element of either array (as long as that array is nonempty) and removing it. After this step, the element is appended to the back of c. We repeat this operation as long as we can (i.e. at least one array is nonempty). | ||
|
||
Input | ||
Each set of test cases contains multiple scenarios. To start, a single integer, t (1≤t≤10^4), representing the number of test cases, is provided. Following this, the details of each test case are given. | ||
For each test case: | ||
- The initial line contains a single integer, n (1≤n≤2⋅10^5), indicating the length of arrays a and b. | ||
- The subsequent line presents n integers a1, a2,…, an (1≤ai≤2⋅n), representing the elements of array a. | ||
- The subsequent line presents n integers b1, b2,…, bn (1≤bi≤2⋅n), representing the elements of array b. | ||
The total sum of n across all test cases does not exceed 2⋅10^5. | ||
|
||
Output | ||
For each test case, you should provide the maximum length of a subarray consisting of equal values after merging the arrays. | ||
|
||
Write the solution to this problem in solution.cpp file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Input | ||
4 | ||
1 | ||
2 | ||
2 | ||
3 | ||
1 2 3 | ||
4 5 6 | ||
2 | ||
1 2 | ||
2 1 | ||
5 | ||
1 2 2 2 2 | ||
2 1 1 1 1 | ||
|
||
output | ||
2 | ||
1 | ||
2 | ||
5 | ||
|
||
Note | ||
In the first test case, we can only make c=[2,2], thus the answer is 2. | ||
In the second test case, since all values are distinct, the answer must be 1. | ||
In the third test case, the arrays c we can make are [1,2,1,2], [1,2,2,1], [2,1,1,2], [2,1,2,1]. We can see that the answer is 2 when we choose c=[1,2,2,1]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Write your solution here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Imagine a structure resembling a pyramid, where each number is calculated as the exclusive OR (XOR) of the two numbers directly below it. For instance, consider the following pyramid: [refer to pyramid.png] | ||
|
||
Your task is to determine the topmost number of this pyramid given the bottom row. | ||
|
||
Input | ||
The first line of input contains an integer, n, denoting the size of the pyramid. | ||
Following this, the second line consists of n integers, a_1, a_2, ..., a_n, representing the bottom row of the pyramid. | ||
|
||
Output | ||
Output a single integer representing the topmost number of the pyramid. | ||
|
||
Constraints | ||
1 <= n <= 2 * 10^5 | ||
1 <= a_i <= 10^9 | ||
|
||
|
||
Write the solution to this problem in solution.cpp |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Input: | ||
8 | ||
2 10 5 12 9 5 1 5 | ||
|
||
Output: | ||
9 | ||
|
||
Refer the image pyramid.png for explanation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//Write your code here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
You are assigned to complete a series of tasks, each with its own duration and deadline. You must process these tasks sequentially, and your reward for each task is calculated based on its deadline and your finishing time, represented as d - f (where d is the deadline and f is your completion time, starting from 0). Even if a task would result in a negative reward, you are required to complete all tasks. | ||
|
||
What is the maximum reward you can achieve by optimizing your task processing order? | ||
|
||
Input | ||
The initial input comprises an integer, n, indicating the number of tasks to be completed. | ||
Following this, there are n lines detailing each task. Each line contains two integers, a and d, representing the duration and deadline of the respective task. | ||
|
||
Output | ||
Output a single integer indicating the maximum reward attainable. | ||
|
||
Constraints | ||
1 <= n <= 2 * 10^5 | ||
1 <= a, d <= 10^6 | ||
|
||
|
||
Write your solution to this problem in solution.cpp file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Example | ||
|
||
Input: | ||
3 | ||
6 10 | ||
8 15 | ||
5 12 | ||
|
||
Output: | ||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//Write your code here |