#QHD0000079. Bữa tiệc trái cây (Fruit Feast)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bữa tiệc trái cây (Fruit Feast)
Fruit Feast
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
Bessie has unlimited supplies of two fruits, oranges and lemons. Eating one orange increases her fullness by exactly units; eating one lemon increases it by exactly units. Her initial fullness is , and her fullness may never exceed .
She can additionally drink water at most once. Drinking water immediately changes her current fullness to . She may drink before, between, or after eating fruits, or skip the water entirely.
Find the maximum fullness achievable by any valid sequence of operations. You do not need to print the operations.
Input
A single line contains three integers .
Output
Print the largest reachable fullness as one integer.
Subtasks
-
Subtask 1 (20 points): , .
-
Subtask 2 (30 points): , .
-
Subtask 3 (50 points): , .
Examples
Example 1
Input
8 5 6
Output
8
Explanation
Eat an orange to reach , drink water to reach , then eat a lemon to reach .
Example 2
Input
10 6 9
Output
10
Explanation
Eat a lemon to reach , drink to reach , and then eat an orange to reach .