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

17819번 - Džumbus 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB32151252.174%

문제

Marin is a good man, so he’ll organize Q parties for his N friends, all of which are competitive programmers. The only drink that is going to be served at his parties will be džumbus — a mixture of Coke and ginger juice.

For each of his friends, Marin knows the amount of džumbus they need to drink in order to relax. He also knows that there are M pairs of people among his friends such that, if both of them are relaxed, they will begin to exchange the solutions of past COCI problems (since there are no published editorials). When a person A shares their solutions with person B, the person B may decide to share those solutions in the same manner, but it is also known that M pairs are formed in a way that it is impossible that those solutions will get back to person A during that party, regardless of the order in which exchanges took place.

Marin has prepared different amounts of džumbus for each party. During each party, he will distribute the drink in a way which maximizes the number of people that will at least once exchange their solutions with another person at that party.

Your task is to determine the number of people that will exchange their solutions for each of the Q parties.

입력

The first line contains integers N and M from the task description.

The second line contains N space separated integers Di, the amounts of džumbus needed to relax Marin’s friends, given in order from a friend number 1 to a friend number N.

The i-th of the next M lines contains two integers Ai and Bi (Ai ≠ Bi), denoting a pair of friends from the task description.

The next line contains an integer Q from the task description.

The next Q lines contain a single integer Si which represents the total amount of džumbus that is going to be served at i-th party

출력

Output the number of people that will exchange their solutions for each of the Q parties. The answer for each party should be given in a separate line. Note that the parties are independent of each other.

제한

In all subtasks, it holds 0 ≤ M < N ≤ 1000, 1 ≤ Q ≤ 2 · 105, 1 ≤ Di ≤ 109 and 1 ≤ Si ≤ 109.

서브태스크

번호배점제한
120

M = N − 1, 1 ≤ Si ≤ 1000, Marin’s friends will be paired up in a way that each friend will exchange their solutions with at most two other people.

230

M = N − 1, Marin’s friends will be paired up in a way that each friend will exchange their solutions with at most two other people.

330

N ≤ 100

430

No additional constraints.

예제 입력 1

1 0
1000
1
1000

예제 출력 1

0

At the first party, Marin decided to relax friends with indexes 1, 2, 3, 7, 9, 10, 12 and 13. They have drunk a total of 45 units of džumbus.

예제 입력 2

3 2
1 2 3
1 2
1 3
3
2
3
5

예제 출력 2

0
2
2

예제 입력 3

14 13
2 3 4 19 20 21 5 22 6 7 23 8 10 14
1 2
1 3
1 4
2 5
2 6
3 7
3 8
3 9
4 10
8 11
10 13
10 12
12 14
3
45
44
23

예제 출력 3

8
7
5

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2019/2020 > Contest #1 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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