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

31205번 - Team Building 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB52266.667%

문제

You aim to assemble a team of $N$ programmers. You've already scouted them and assessed that the skill level of the $i$-th individual (1ドル ≤ i ≤ N$) is represented by the nonnegative integer $s[i]$. You've realized that what truly matters is the order in which you hire them.

Each programmer is characterized by two additional integer values: workrate and motivation, both of which are 0ドル$ upon their arrival but can increase after hiring new team members. When a new programmer is hired, the following events occur in the given order:

  • The new programmer joins the team with workrate and motivation initialized to 0ドル$.
  • The workrate of each other previously hired programmer is increased by their own motivation value.
  • The motivation of each other previously hired programmer is increased by the skill level of the new hire.

The strength of the team is determined afterwards by the sum of the workrates of all the team members. Your objective is to calculate the maximum attainable team strength by optimizing the order of hiring.

For example, if you hire programmers with skill levels $(0, 2, 2, 3)$ in this order, the hiring process will affect their values as follows:

Event Workrates Motivations
Hiring with skill 0ドル$ 0ドル$ 0ドル$
Hiring with skill 2ドル$ 0ドル$ 0ドル$ 0ドル$ 0ドル$
Workrates update 0ドル$ 0ドル$ 0ドル$ 0ドル$
Motivations update 0ドル$ 0ドル$ 2ドル$ 0ドル$
Hiring with skill 2ドル$ 0ドル$ 0ドル$ 0ドル$ 2ドル$ 0ドル$ 0ドル$
Workrates update 2ドル$ 0ドル$ 0ドル$ 2ドル$ 0ドル$ 0ドル$
Motivations update 2ドル$ 0ドル$ 0ドル$ 4ドル$ 2ドル$ 0ドル$
Hiring with skill 3ドル$ 2ドル$ 0ドル$ 0ドル$ 0ドル$ 4ドル$ 2ドル$ 0ドル$ 0ドル$
Workrates update 6ドル$ 2ドル$ 0ドル$ 0ドル$ 4ドル$ 2ドル$ 0ドル$ 0ドル$
Motivations update 6ドル$ 2ドル$ 0ドル$ 0ドル$ 7ドル$ 5ドル$ 3ドル$ 0ドル$

The team strength will be calculated as 6ドル + 2 + 0 + 0 = 8$. However, if you hire programmers in better order $(2, 2, 3, 0),ドル you will achieve a team strength of 7ドル + 3 + 0 + 0 = 10$.

New hire skill Workrates Motivations
2ドル$ 0ドル$ 0ドル$
2ドル$ 0ドル$ 0ドル$ 2ドル$ 0ドル$
3ドル$ 2ドル$ 0ドル$ 0ドル$ 5ドル$ 3ドル$ 0ドル$
0ドル$ 7ドル$ 3ドル$ 0ドル$ 0ドル$ 5ドル$ 3ドル$ 0ドル$ 0ドル$

Furthermore, over the course of the upcoming $Q$ days, you will receive notifications about changes in the skill level assessments of certain programmers. After day $i,ドル the skill level of programmer $x[i]$ will be updated to $y[i]$ (which may match the previous value). This updated skill value will be used in the following days, until it potentially gets updated again.

After each day, starting from today, your goal is to determine the maximum achievable team strength by hiring all $N$ programmers, taking into account the assessed skill levels at that particular moment.

입력

The first line contains two integers: $N$ and $Q$.

The second line contains integers: $s[1],ドル $s[2],ドル $\dots,ドル $s[N]$.

Subsequently, there are $Q$ lines, the $i$-th of which contains two integers: $x[i]$ and $y[i]$.

출력

Print $Q + 1$ lines, each containing a single integer. These integers represent the maximum potential team strength after each day, in chronological order.

제한

  • 2ドル ≤ N ≤ 50,円 000$
  • 1ドル ≤ Q ≤ 100,円 000$
  • 0ドル ≤ s[i] ≤ 100,円 000$ for each 1ドル ≤ i ≤ N$.
  • 1ドル ≤ x[i] ≤ N$ for each 1ドル ≤ i ≤ Q$.
  • 0ドル ≤ y[i] ≤ 100,円 000$ for each 1ドル ≤ i ≤ Q$.

서브태스크

번호배점제한
111

$N ≤ 7$; $Q ≤ 100$

219

$N,Q ≤ 500$

315

$Q ≤ 10$

46

The skill levels never exceed 1ドル$.

59

The skill levels never exceed 500ドル$.

612

$x[i] = 1$ for each 1ドル ≤ i ≤ Q$.

710

Each update will change the skill level by at most 1ドル$.

818

No additional constraints.

예제 입력 1

4 2
2 0 2 3
2 4
4 0

예제 출력 1

10
14
12

The solution for the initial state is illustrated above. After the first day, the skill levels will be updated to $(2, 4, 2, 3)$ and the maximum attainable team strength becomes 14ドル,ドル and after the second day, they will be further adjusted to $(2, 4, 2, 0)$.

힌트

출처

Olympiad > European Junior Olympiad in Informatics > eJOI 2023 6번

채점 및 기타 정보

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

출처

대학교 대회

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

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