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

33660번 - Coin Exchange 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB766100.000%

문제

Lorenzo of Valtier is a traveling merchant navigating the fractured realms of the Five Kingdoms. Each nation mints its own unique coins using secretive forging techniques, creating a hidden economy of conversions:

Currencies

  • Aetherspire Dominion: Obsidian discs etched with celestial runes (Aetherspire Coin)
  • Bleakmarch Protectorate: Bone-white tetrahedrons that scream when heated (Bleakmarch Coin)
  • Crimson Falconate: Blood-veined square that warm before storms (Crimson Coin)
  • Drowned King’s Reach: Barnacle-encrusted hexagons that smell of brine (Drowned Coin)
  • Emberveil Syndicate: Geometric amber prisms containing frozen flames (Emberveil Coin)

Exchange Rates (Black Market, One-way Currency Exchange):

  • 3ドル$ Aetherspire $→$ 1ドル$ Bleakmarch ("Three stars bow to the Pale Lord")
  • 3ドル$ Bleakmarch $→$ 1ドル$ Crimson ("The Bloodied Falcon’s Toll")
  • 5ドル$ Aetherspire $→$ 1ドル$ Crimson ("Stardust to Blood" smuggling route)
  • 3ドル$ Emberveil $→$ 2ドル$ Drowned ("Fire drowns in black waters")
  • 3ドル$ Bleakmarch $→$ 4ドル$ Emberveil ("Bleaching the Pale Mark")

Forbidden Technique: The Argentum Revenant Tome allows you to exchange 2ドル$ Drowned $→$ 3ドル$ Bleakmarch ("Raising Drowned Silver") for a maximum of $X$ uses, after which the Pale Inquisition is triggered.

Given Lorenzo of Valtier’s initial coin stash and a limit of $X$ on the number of times the forbidden technique may be used, your goal is to maximize the number of Crimson Falconate coins that can be obtained using a series of exchanges. Solving this puzzle may unlock the secret behind how Lorenzo of Valtier became wealthy!

Figure 1: Echange Rates. (Coin images created by DALL·E-3)

입력

A line containing six integers: $A$ (Aetherspire Coin), $B$ (Bleakmarch Coin), $C$ (Crimson Coin), $D$ (Drowned Coin), $E$ (Emberveil Coin), $X$ (maximum use of the Forbidden Technique) satisfying 0ドル≤A,B,C,D,E,X≤10^9$.

출력

A single integer indicating the number of maximum possible Crimson Coins that can be obtained using a series of zero or more of exchanges.

제한

예제 입력 1

1 2 3 4 5 6

예제 출력 1

7

Lorenzo of Valtier can obtain 7ドル$ Crimson coins using the following sequence of exchanges beginning with the initial coin count of $(A,B,C,D,E)=(1,2,3,4,5)$.

  • 3ドル$ Emberveil coins are converted to 2ドル$ Drowned coins. The coin count is now $(1,2,3,6,2)$.
  • Using the forbidden exchange three times, 6ドル$ Drowned coins are converted to 9ドル$ Bleakmarch coins. The coin count is now $(1,11,3,0,2)$.
  • 6ドル$ Bleakmarch coins are converted to 8ドル$ Emberveil coins. The coin count is now $(1,5,3,0,10)$.
  • 9ドル$ Emberveil coins are converted to 6ドル$ Drowned coins. The coin count is now $(1,5,3,6,1)$.
  • Using the forbidden exchange three more times, 6ドル$ Drowned coins are converted to 9ドル$ Bleakmarch coins. The coin count is now $(1,14,3,0,1)$.
  • Finally, 12ドル$ Bleakmarch coins are converted to 4ドル$ Crimson coins. The final coin count is now $(1,2,7,0,1)$.

Note that the forbidden exchange was not used more than $X=6$ times.

예제 입력 2

5 5 5 5 5 5

예제 출력 2

11

예제 입력 3

1000000000 0 500000000 123 456789 1000000000

예제 출력 3

950114243

힌트

출처

University > University of Alberta Programming Contest > UAPC 2025 > Division 1 H번

University > University of Alberta Programming Contest > UAPC 2025 > Division 2 J번

  • 문제를 만든 사람: Answer
(追記) (追記ここまで)

출처

대학교 대회

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

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