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

32506번 - Rhythm Flow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB71424166.129%

문제

You are designing a scoring algorithm for the new hit rhythm game Rhythm Flow where players must press a button in time to the music. During a round of Rhythm Flow, there are points in time when a visual indicator flashes on the screen. Players are expected to press the button at those times (and only at those times). However, since human reaction time is not instantaneous, the game gives the player some leeway and accepts a button press a few milliseconds earlier or later than expected. More accurate presses are worth more points.

The following table lists how many points a player gets depending on how far away the actual button press is from the expected button press, in milliseconds:

Time Difference (ms) Points
$[0,15]$ 7
$(15,23]$ 6
$(23,43]$ 4
$(43,102]$ 2

Wildly inaccurate presses with a difference of 103ドル$ milliseconds or more score no points.

During gameplay, the player presses the button some number of times. To score the game, match each actual button press with at most one expected button press, with the following restriction: if one actual button press happens before another actual button press and both button presses are matched with expected button presses, then the expected button press for the first must be strictly before the expected button press for the second.

Because you are generous, you decide to compute the matching that maximizes the number of points the player earns. Compute the final score of the round of Rhythm Flow under this matching.

입력

The first line contains two integers $n$ and $m$ (1ドル≤n,m≤2,000円$), where $n$ is the number of expected button presses and $m$ is the number of actual button presses.

Each of the next $n$ lines contains a single integer $e$ (1ドル≤e≤10^9$). These are the times of the expected button presses in milliseconds from the start of the round. It is guaranteed that these values are unique and in sorted order.

Each of the next $m$ lines contains a single integer $a$ (1ドル≤a≤10^9$). These are the times of the actual button presses in milliseconds from the start of the round. It is guaranteed that these values are unique and in sorted order.

출력

Output a single integer: the total number of points the player earns given a maximally-generous scoring engine.

제한

예제 입력 1

3 4
100
200
300
99
201
240
323

예제 출력 1

20

예제 입력 2

4 3
1000
2000
2500
3000
1103
2598
4000

예제 출력 2

2

예제 입력 3

2 2
100
144
56
100

예제 출력 3

7

힌트

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2024 K번

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

출처

대학교 대회

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

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