AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

DAPC25-072.Koehandel

Medium · 1 s · 256 MB

  • icpc
  • dapc
  • 2025

You are playing a game of Betting and Purchasing Cows (BAPC), and Old MacDonald wants to buy one of your cows using a bid-off. This works as follows.

He bets some number of BAPC coins, which he puts in a cup that he places upside down on the table. You then openly bet some number of your own coins. The cup is removed to reveal MacDonald's bet. The bets are exchanged: you receive the bet from MacDonald and he receives your bet. The player that bet the most BAPC coins receives one cow from the opponent, regardless of who started the bidding. In case of a tie, no cows are exchanged.

You love the cows in the game, so your primary goal is to have the most possible cows after the trade. Your secondary goal is to have the highest possible number of coins after the trade. You pay close attention when Old MacDonald is secretly putting their coins in the cup, and by listening very carefully, you have determined the exact number of coins that he put in the cup. Given this information and the number of coins you have, how many coins should you bet?

Giriş formatı

The input consists of:

• One line with two integers ccc and nnn (0≤c,n≤1090\leq c, n\leq 10^90≤c,n≤109), the number of BAPC coins in Old MacDonald's cup and the number of coins that you have.

Çıxış formatı

Output the number of coins that you should bet, keeping your goals in mind.

Qeyd

Source: Delft Algorithm Programming Contest 2025 · Author: Mike de Vries · License: CC BY-SA 4.0 · Original: https://dapc.wisv.ch · Statement adapted for AlgoLens and shared under the same license.

Nümunələr

Giriş #1

6 19

Çıxış #1

7

Giriş #2

42 37

Çıxış #2

0

Giriş #3

25 25

Çıxış #3

25