PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000124. Điểm số trong giải bóng đá (Football)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Điểm số trong giải bóng đá (Football)
Football
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A football team played games. In game it scored goals and conceded . A win earns points, a draw , and a loss . You may add at most goals to the team’s scores across all games. Maximize total points.
Input
The first line has . The following lines each contain .
Output
Print the maximum total points.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3 2
1 1
0 1
2 0
Output
7
Explanation
Initial score is . Spend one extra goal to turn the draw into a win (+2), and one to turn the loss into a draw (+1), yielding .