포럼
문제 ICPC00369

E. Excruciating Elevators

설명

It is the 25th of May, 3025. The EEMCS building at TU Delft has grown to \(10^6\) floors beyond the ground floor! The floors are now numbered \(0,1,\ldots,10^6\), but there are still only four elevators. Moreover, the elevators have malfunctioned and are currently turned off. As employee of the Building Ascension Plans Company, you are tasked to fix the elevators.

You first have to order some components, which will take a month to arrive at the ground floor. After collecting the components, you must visit \(n\) floors \(f_1,\ldots,f_n\) in order. At each floor \(f_i\), you must replace some component, which takes \(t_i\) seconds. After replacing the final component, the elevators will be fixed.

The stairs have long been removed, since people got tired of walking up millions of flights of stairs. You thus have to use the elevators to travel between the floors. You can turn on the elevators, but when you turn one on, you can no longer turn it off. Once turned on, an elevator will move up and down between floors \(0\) and \(10^6\) indefinitely. The elevators move at a speed of one floor every second without stopping, but you are agile enough to enter and exit.

You know exactly when the components will arrive. In the meantime, you can determine when to turn on each elevator. This timing determines the starting configuration of each elevator when the components arrive. Since you have a month, you can enforce any arbitrary starting configuration of the elevators. What is the minimum possible time to fix the elevators?

As an example, consider the first sample input. You can ensure one elevator starts at ground floor going up, and another starts at floor \(750\,000\) going up. Entering the former elevator immediately, you arrive at floor \(600\,000\) after \(600\,000\) seconds. After \(50\,000\) more seconds, you finish replacing the component at floor \(600\,000\). In the meantime, the latter elevator reached the top floor after \(250\,000\) seconds, when it started going down. Now, \(400\,000\) seconds later, this elevator is at floor \(600\,000\) going down. You can enter this elevator immediately and exit \(200\,000\) seconds later at floor \(400\,000\). Finally, after \(150\,000\) seconds, you finish replacing the component at floor \(400\,000\), and the elevators are fixed! The total time is \(600\,000+50\,000+200\,000+150\,000=1\,000\,000\) seconds.

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(1\leq n\leq 35\)), the number of floors to visit.
- One line with \(n\) integers \(f_1,\ldots,f_n\) (\(0\leq f_i\leq10^6\) for each \(i\)), the numbers of the floors you must visit.
- One line with \(n\) integers \(t_1,\ldots,t_n\) (\(1\leq t_i\leq10^9\) for each \(i\)), the necessary time spent on each floor in seconds.

No two consecutive floors \(f_i,f_{i+1}\) are equal, and \(f_1\) is non-zero.

출력 형식

Output the minimum possible time in seconds to fix the elevators after the components have arrived and you start at the ground floor.

예제 1
입력
2
600000 400000
50000 150000
출력
1000000
예제 2
입력
10
1 2 3 4 5 6 7 8 9 10
1 1 1 1 1 1 1 1 1 1
출력
4000012
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2025

평가 및 의견

E. Excruciating Elevators

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

E. Excruciating Elevators

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8