Logo
(追記) (追記ここまで)

27881번 - Gahui and ILGAM lake 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB89363454.839%

문제

Gahui often visited Konkuk University. Every time Gahui visited Konkuk University, she was surprised to see the huge ILGAM lake. It is bigger than several universities, such as Seokyung university and Hanseong university.

The lake has 4n points arranged like a ring, each numbered from 1 to 4n in counter-clockwise order. Each pair of adjacent points are connected in both directions. In other words:

  • If 1a < 4n, point a is connected to point a+1 in both directions.
  • Point 1 is connected to point 4n in both directions.

Points n, 2n, 3n, and 4n are connected to 3 subway stations (Konkuk_Univ, Guui, Sejong_Univ) via roads. ILGAM lake is so big, the nearest station is different depending on the point. Gahui wants to know which subway station is the nearest to her current point. Please help Gahui.

[Picture 1] Roads and points when n = 2

입력

n is given in the first line.

In the next line, 4n numbers are given in the following format:

d1 d2 ... d4n

  • di is distance from point i to point i+1 when 1i<4n
  • d4n is distance from point 4n to point 1

And the information below is given on four lines.

dn,Konkuk_Univ dn,Guui dn,Sejong_Univ

d2n,Konkuk_Univ d2n,Guui d2n,Sejong_Univ

d3n,Konkuk_Univ d3n,Guui d3n,Sejong_Univ

d4n,Konkuk_Univ d4n,Guui d4n,Sejong_Univ

da,b is the distance between point a and station b.

In the next line, Q (number of questions) is given.

In the next Q lines, Q questions are given in the following format, one per line.

  • k
    • What is the distance to the nearest station from point k?

출력

Print the answers to the questions, one per line.

제한

  • 1all distances in the problem105
  • 1n105
  • 1Q105

예제 입력 1

1
1 1 1 1
999 999 999
888 888 888
1 2 3
888 888 888
1
1

예제 출력 1

3

Move from point 1 to point 3. Then, move from point 3 to Konkuk_Univ Station.

예제 입력 2

1
100 90 80 1
999 999 999
888 888 888
777 777 777
1 1 1
1
1

예제 출력 2

2

노트

출처

Contest > BOJ User Contest > 가희와 함께 하는 코딩 테스트 > 가희와 함께 하는 5회 코딩테스트 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /