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

9801번 - Commuter train 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 64 MB222100.000%

문제

You might have noticed that bus drivers sometimes pass by passengers waiting for the bus and stop at a place where the distance from the people to the bus doors is maximal. We don’t know exact reasonsof such behaviour, probably, this is done not because of some special wickedness of the driver but in order to allow passengers in the vehicle to get off quicker. However, we know that in one far-away countrythe government decided to implement automatic driving system on their commuter railroads. Amongother features, this system is intended to automatically stop commuter trains at stations. A computer in the train is connected to a special radar, which determines passenger positions at the station platform. The computer decides where to stop the train in order to maximize the sum of the distances from each passenger to the closest door. All the hardware is ready, but the software project is late (transport problems). Your task is to implement this function for this software project.

More precisely: The platform has length 0 < L ≤ 5000. There are 0 < M ≤ 300 passengers at the station platform. Each passenger p has position Pp (0 ≤ P1 ≤ ... ≤ PM ≤ L) — the distance from the platform beginning to the passenger. There are 0 < N ≤ 300 doors in the train. Each door d has position Dd (0 = D1 < D2 < ... < DN ≤ L) -- the distance from it to the door 1. The door width and the passenger sizes are not taken into account. For simplicity, you can assume that the distance between a passenger i and a train door j is dist(i, j, S) = |Dj + S - Pi|, where S is train position -- the distance between the first door and the beginning of the platform. Remember that the train must stop so that no door is outside of the platform.

입력

The input contains integer numbers, separated by spaces and/or line feeds. At the beginning of the file there is the station description L, M, and P1 ... PM, followed by the train description N and D2 ... DN.

출력

You should output two numbers -- the train position S, at which the maximal possible sum of the minimal distances between the passengers and the doors can be achieved and the sum by itself. If there are many such train positions -- output any one.

제한

예제 입력 1

4
5
0 1 2 3 4
4
1 2 3

예제 출력 1

0.5 2.5

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2002 D번

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

출처

대학교 대회

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

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