#abc298f. F - Rook Score
F - Rook Score
Score : points
问题描述
我们有一个拥有 行和 列的网格。令 表示从上到下的第 行、从左到右的第 列的方格。
对于 ,在坐标为 的方格上写有一个正整数 。在其余的 个方格上,都写有数字 。
你选择一个方格 并计算与 共享行或列的 个方格上的整数之和 。
找出 可能的最大值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a grid with rows and columns. Let denote the square at the -th row from the top and -th column from the left.
For , a positive integer is written on . On the other squares, is written.
You choose a square and compute the sum of the integers written on the squares that share a row or column with .
Find the maximum possible value of .
Constraints
- if .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
1 1 2
1 2 9
2 1 8
3 2 3
Sample Output 1
20
If you choose as , then will be , which is the maximum possible value.
Sample Input 2
1
1 1000000000 1
Sample Output 2
1
Sample Input 3
15
158260522 877914575 602436426
24979445 861648772 623690081
433933447 476190629 262703497
211047202 971407775 628894325
731963982 822804784 450968417
430302156 982631932 161735902
880895728 923078537 707723857
189330739 910286918 802329211
404539679 303238506 317063340
492686568 773361868 125660016
650287940 839296263 462224593
492601449 384836991 191890310
576823355 782177068 404011431
818008580 954291757 160449218
155374934 840594328 164163676
Sample Output 3
1510053068
update @ 2024/3/10 12:22:48