RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00096

A. Cakey McCakeFace

설명

Cakey McCakeFace's signature pastry, the Unknowable Cake, is baked daily in their Paris facility. The make-or-break trick for this cake is the cooking time, which is a very well-kept secret. Eve, the well-known spy, wants to steal this secret, and your job is to help her.

Cakes are cooked in a single huge oven that has exactly one front and one back door. The uncooked cakes are inserted through the front door. After the exact and very secret cooking time has passed, the cakes exit the oven through the back door. Only one cake can go through the front or back door at any given time.

Eve has secretly installed detectors at the front and back of the oven. They record a signal every time a cake passes through the doors. A cake will therefore trigger the entry detector at some time \(t\) when it goes through the front door, and then trigger the exit detector at time exactly \(t\) + cooking_time when it goes through the back door (all cakes at Cakey McCakeFace are always perfectly cooked).

After a few days, she receives two sets of timestamps (in ms) corresponding to entry and exit detectors. Unfortunately, the detectors are faulty: they are sometimes triggered when no cake has passed, or they may fail to be triggered when a cake passes. Eve noticed that she could make a good guess of the secret cooking_time by finding the time difference that maximizes the number of correspondences of entry and exit detection times. Help Eve compute this.

제약
입력 형식
  • Line 1: the number \(N\) of times the entry detector was triggered.
  • Line 2: the number \(M\) of times the exit detector was triggered.
  • Line 3: the \(N\) integer timestamps at which the entry detector was triggered, sorted in ascending order, with no repetition, space-separated.
  • Line 4: the \(M\) integer timestamps at which the exit detector was triggered, sorted in ascending order, with no repetition, space-separated.

Limits
- \(1\leq N,M \leq 2\,000\);
- each timestamp is between 0 and \(1\,000\,000\,000\) (inclusive).

출력 형식

A single integer: your best guess of the secret cooking_time, the (positive or zero) time difference that maximizes the number of correspondences of entry and exit detection times. If multiple such values exist, the smallest one should be returned.

예제 1
입력
5
5
0 10 12 20 30
1 5 17 27 50
출력
5
문제 정보

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

출처 ICPC SWERC 2017

평가 및 의견

A. Cakey McCakeFace

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

Log in to rate problems.

개별 의견

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

풀이 제출

A. Cakey McCakeFace

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