아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

P-22 is ready for his Closeup

시간 제한5초메모리 제한1024 MB

요약
카메라 설치와 퓨마 목격을 (시간, 장소) 쌍으로 주어질 때, 시각과 장소가 정확히 일치하는 경우의 최대 글래머를 구한다.
난이도

보통10점 중 4점

유형
정렬, 해시맵, 구현
정답자
아직 제출이 없습니다

문제

P-22 rose to national fame when Steve Winter published a photo of P-22 in front of the Hollywood Sign in National Geographic. To do so, Winter spent 15 months placing motion-activated cameras in the park, trying to understand P-22’s movements. After all, Griffith Park is pretty big, so going to a random spot at a random time was unlikely to result in meeting P-22 — but if you repeat a random attempt often enough, there’s a decent chance you’ll succeed at least once. Here, you will be given a list of where Winter set up his camera at various times, and where P-22 was at various times, and you are to find out what was the most glamorous shot of P-22 that Winter captured.

입력

The first line is the number 1 ≤ K ≤ 100 of input data sets, followed by K data sets, each of the following form:

The first line contains three integers 1 ≤ L ≤ 1000, 0 ≤ n, m ≤ 500000. L is the number of locations which Winter considered, n is the number of times he set up a camera, and m is the number of recorded positions for P-22.

Next is a line with L integers gℓ > 0, where gℓ is the glamour of getting a shot in location i. Next, there are n lines, each describing a (integer) time ti > 0 and location ℓi ∈ {1, . . . , L} for a camera setup. There may be multiple camera setups at the same time. Finally, there are m lines, each describing the (integer) time tj > 0 and location ℓj ∈ {1, . . . , L} where P-22 was known to have been. Here, obviously, there will not be two sightings at the same time. All input numbers will comfortably fit in a 32-bit integer.

출력

For each data set, output “Data Set x:” on a line by itself, where x is its number. Then, output the maximum glamour of any possible shot. A shot is possible if P-22 was in a location ℓ at the same time as a camera was set up there — in that case, the shot produced has glamour gℓ. If P-22 was never in a spot where there was a camera, then the maximum glamour is 0.

Each data set should be followed by a blank line.

예제1

  1. 예제 1

    입력
    2
    2 4 3
    3 5
    5 2
    5 1
    2 2
    8 1
    8 1
    4 2
    8 2
    1 1 1
    10
    2 1
    1 1
    
    예상 출력
    Data Set 1:
    3
    
    Data Set 2:
    0