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

Džumbus

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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.

제약

In all subtasks, it holds \(0 \le M < N \le 1000\), \(1 \le Q \le 2 \cdot 10^{5}\), \(1 \le D_{i} \le 10^{9}\) and \(1 \le S_{i} \le 10^{9}\).
Subtask
Score
Constraints
1
20
\(M = N - 1\), \(1 \le S\)\(i \le 1000\),
Marin’s friends will be paired up in a way that each friend
will exchange their solutions with at most two other people.
2
30
\(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.
3
30
\(N \le 100\)
4
30
No additional constraints.

입력 형식

The first line contains integers \(N\) and \(M\) from the task description.
The second line contains \(N\) space separated integers \(D_{i}\), 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 \(A@@RISE_MATH_BLOCK_0@@i\) (\(A@@RISE_MATH_BLOCK_1@@i\)), 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 \(S\)\(i\) 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.

예제 1
입력
1 0
1000
1
1000
출력
0
예제 2
입력
3 2
1 2 3
1 2
1 3
3
2
3
5
출력
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
출력
8
7
5
설명

Clarification of the third example: 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.

문제 정보

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

출처 COCI 2019/2020 Contest 1

평가 및 의견

Džumbus

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

Log in to rate problems.

개별 의견

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

풀이 제출

Džumbus

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