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

32449번 - Animal Farm 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB33320917161.511%

문제

On Animal Farm, the animals have rebelled against their human owner and have taken over the management of the farm. To ensure equality and fairness among all the animals, they have decided to create a new set of rules. However, as the new leaders, the pigs have started making changes to the rules to favor themselves.

The farm maintains a hierarchy of animals based on their species, with each animal assigned a specifc infuence level. This infuence level, represented as a positive integer, determines the animal’s priority in decision-making. Within a group, an animal can make decisions if it has the highest influence level among the members.

The pigs have a plan to maximize their collective infuence in the leadership council by selecting a specific group of animals. Given a list of animals with their species and influence levels, you are tasked to form the most influential leadership council while adhering to the following rules:

  1. Only one pig species is allowed in the council to avoid power conflicts among the pigs.
  2. Every council member of non-pig species should have an influence level less than the influence level of the only pig’s in the council.

Determine the maximum total influence levels of the council that can be formed under these rules.

입력

The first line contains an integer $n,ドル representing the number of animals. The next $n$ lines each contain a string species and a positive integer influence:

  • species is a string representing the species of the animal, e.g., “pig”, “horse”, “cow”, etc.
  • influence is an integer representing the influence level of the animal.

출력

Output a single integer, the maximum total influence levels of the leadership council that can be formed following the rules.

제한

  • 1ドル ≤ n ≤ 10^5$.
  • The length of species is at most 10ドル$.
  • species consists of only English characters in lowercase.
  • At least one animal’s species is pig.
  • influence is at most 10ドル^8$.

예제 입력 1

5
pig 10
horse 15
pig 5
cow 20
sheep 25

예제 출력 1

10

예제 입력 2

5
pig 10
horse 15
pig 15
cow 15
sheep 10

예제 출력 2

25

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2024 A번

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

출처

대학교 대회

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

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