harbor run -t openthoughts/tasktrove-exp-rpt-taco-v2-taco-7209harbor download openthoughts/tasktrove-exp-rpt-taco-v2-taco-7209You are tasked with programming a robot that navigates a grid consisting of 2 rows and m columns. The rows are numbered 1 to 2 from top to bottom, and the columns are numbered 1 to m from left to right.
The robot starts at position (1, 1). In one second, it can perform one of the following actions:
The robot is constrained by the grid boundaries and is not allowed to move outside the grid.
Initially, all cells (except for the cell (1, 1)) are locked. Each cell (i, j) has a value a[i][j], which signifies the moment in time at which that cell becomes unlocked. The robot can only move into cell (i, j) after at least a[i][j] seconds have elapsed.
The objective is for the robot to visit all cells in the grid without entering any cell more than once (the cell (1, 1) is considered entered at the start). The robot can finish in any cell after visiting all the others.
Your task is to determine the minimum amount of time required for the robot to complete its traversal.
t (1 ≤ t ≤ 10^4) — the number of test cases.For each test case:
m (2 ≤ m ≤ 2 * 10^5) — the number of columns in the grid.m integers:
a[1,1], a[1,2], ..., a[1,m] (for row 1)a[2,1], a[2,2], ..., a[2,m] (for row 2)0 ≤ a[i,j] ≤ 10^9 for all i, j. The value at a[1,1] is always 0 (the starting cell is unlocked).The sum of m over all test cases will not exceed 2 * 10^5.
For each test case, print a single integer — the minimum number of seconds required for the robot to visit all cells without revisiting any cell.
4
3
0 0 1
4 3 2
5
0 4 8 12 16
2 6 10 14 18
4
0 10 10 10
10 10 10 10
2
0 0
0 0
5
19
17
3
No additional notes.
Please place your solution in the /app/ directory of your project.
Important: place your implementation at /app/solution.py so the verifier can run it.