Climbing to the Information Science Building
InterviewTime limit2sMemory limit512 MB
Find the crossing point k minimizing left-road distance from 1 to k plus crosswalk k plus right-road distance from k to n; output the smallest such k and the minimum distance.
- Level
Medium4 of 10
- Topics
- Prefix sum, Array, Implementation, Brute force
- Solved
- No attempts yet
Problem

The Information Science Building at Soongsil University sits on the highest spot of the campus. Minju usually rides the bus up this hill, but for today only she walks up.
Two roads lead up to the building, a left road and a right road. Both roads wind a lot. Minju is at the bottom of the left road, and the building is at the top of the right road.
The hill has points numbered to from bottom to top, and each point has one crosswalk that joins the left road and the right road. Minju can cross a crosswalk only once.
Her route therefore starts at point on the left road, goes up, crosses the crosswalk at some point , and continues up the right road to point . The distance she walks is the sum of the distance along the left road from point to point , the length of the crosswalk at point , and the distance along the right road from point to point .
Find the number of the crosswalk Minju crosses when she walks the shortest distance, and that distance, and help her through the hot summer.
Input
The first line has the number of points . ()
The second line has the length of the crosswalk at point , for up to in order.
The third line has the distance on the left road from point to point , for up to in order.
The fourth line has the distance on the right road from point to point , for up to in order.
Every distance is a positive integer at most .
Output
Print the number of the point whose crosswalk Minju crosses on a shortest walk, then the distance she walks, separated by one space on a single line.
If several points give the minimum distance, print the smallest point number.