トヨタ自動車プログラミングコンテスト2024#4(AtCoder Beginner Contest 348)
翻译中…
Problem Statement
翻译中…
You are given two integer sequences $A$ and $B$ of length $N$. For $k = 1, 2, \ldots, N$, solve the following problem:
翻译中…
- Consider choosing
$k$distinct integers between$1$and$N$, inclusive. Let$S$be the set of chosen integers. Find the maximum value of$\displaystyle (\sum_{i \in S} A_i) - \max_{i \in S} B_i$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$$-10^9 \leq A_i \leq 10^9$$-2 \times 10^{14} \leq B_i \leq 2 \times 10^{14}$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
A_1 B_1
A_2 B_2
\vdots
A_N B_N
翻译中…
Output
翻译中…
Print $N$ lines. The $i$-th line should contain the answer to the problem for $k=i$.
翻译中…
样例
Input #1
3
4 1
5 6
3 2
Output #1
3
5
6
The following choices are optimal.
- $k = 1$: $S = \{1\}$
- $k = 2$: $S = \{1, 3\}$
- $k = 3$: $S = \{1, 2, 3\}$
Input #2
2
0 1
0 1
Output #2
-1
-1
Input #3
6
9 7
2 4
7 1
-1000 0
3 4
8 5
Output #3
6
10
17
20
22
-978
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。