P18655 [HackerEarth] View Russian Translation
普及
题目描述

View Russian Translation

From the beginning Benny was a very harsh pig.

She lives in a huge city. City can be determined as a grid with N lines and M columns. The city contains some houses. Each house has it's own beauty. Beauty of house at point(i, j) is Ai, j.

To make city more beautiful Benny decides to destroy some houses. If Benny has destroyed COUNT lines and columns of the city in total and sum of beauty of not destroyed houses is SUM then the beauty of the city is SUM - COUNT * C. Where C is some integer, called coefficient of destruction.

Benny is going to destroy houses in such way: She chooses some line or column and destroy all houses in this line or column.

You task in to find the maximum beauty of the city that Benny can reach after destroying some houses.

Input format

The first line contains three integers N, M, C.
The following N lines contain M integers Ai, j denoting the beauty of the house at point(i, j).

Output format

Print only one integer - maximal beauty of the city that Benny can reach by destroying some houses.

Constraints
1 ≤ N, M ≤ 20
0 ≤ C ≤ 1000
-10000 ≤ Ai, j ≤ 10000
2 ≤ N + M ≤ 20 holds for test cases worth 20% of the problem's score.

Sample Explanation

You have to destroy only first line and then the result beauty of the city will be 2.

SAMPLE INPUT
3 3 2
-1 1 -2
-1 -1 2
6 -1 -1

SAMPLE OUTPUT
2

输入格式

见题面

输出格式

见题面

样例输入
20 20 889 -6553 -9251 -4384 -8093 -241 -6819 -7363 1884 225 2775 3071 2432 -7074 -2986 -3797 -4772 -7761 -1584 -9358 4520 -2143 -1741 440 -4061 -183 244 4409 -3123 -7861 -2900 -6716 3505 -4219 -7280 4416 -1436 -6763 -1705 -6359 2230 -3382 1893 -8220 3619 -5262 -1775 -8912 -9828 -3203 -1368 4357 4136 538 1593 1077 -122 -2300 -3062 -2525 -1672 749 -6726 -3572 2340 -7596 -7311 -9396 901 2046 -931 2219 -2812 -8749 -2311 1125 -4411 -8154 -792 -3601 3813 -4766 -2733 -9728 -1779 -809 -5457 -9706 -6459 2798 -6883 729 -5997 -9973 3164 -1137 -9253 -5053 2809 -1187 -3534 4218 -5982 -8187 4514 671 4059 3473 -1856 -4685 -7190 -4211 -3249 -9386 4594 -4395 4418 -8836 -938 -6748 -8847 -1936 -5192 4902 1304 -5124 -9522 1613 -3814 2809 -8206 -7755 -5551 -1834 -1023 2817 -2428 2477 -2488 -7671 -7761 4757 -7129 -6433 -6919 -7592 -2869 -64 -3580 -317 2634 -713 -6609 1564 -2778 -4914 -6252 -6434 4048 234 2400 -7460 1556 -452 -95 -5365 651 4142 -8981 -3249 4843 -143 -5127 -3498 2525 -8358 -5433 4443 -2813 -9887 -7699 -9352 2468 -5652 2130 -3613 -9667 -1875 -622 3227 2077 -4787 1297 -7097 -5494 4538 -5795 395 -1925 -8973 -4739 -3284 -4454 -8180 -4735 2923 -1765 -7503 -2696 -9348 2234 -3349 -3050 -6679 -6401 -9264 2989 -6076 10 1739 -2903 1028 -4114 -7214 -2240 -5607 -5834 2863 3187 -9093 -2045 -3135 252 267 1078 -393 -6811 2566 -9984 3646 1306 -2344 2154 3071 -6746 -5307 -5935 -6416 2450 -2199 -2795 2226 -4653 4422 -9261 3017 -7983 -6348 -5789 -9268 -6474 -3156 -3753 299 2561 3732 2712 -2386 -5918 -5079 -5495 -7412 -3542 4915 -2572 -5254 94 2960 -5105 3084 -1790 1497 114 402 -9059 -40 -7336 -3625 2455 3282 3561 -970 -1804 -7211 1106 -4786 -6514 -4179 -8995 1454 4580 -5869 -6231 -6140 -1286 139 -4042 -2762 -4463 -8501 -3932 2097 -4442 -6919 -3077 4326 4571 -180 3022 -2258 4462 1935 -9876 -4032 4045 -9681 -924 -7708 -4160 -4232 1342 650 -5924 -5700 3672 -141 -6319 -9244 -6319 -9094 304 -2034 -5550 -6098 4944 -453 -7996 -39 -5217 822 3571 -4345 -9984 -3296 -1258 -5263 -7681 -2143 -7262 -698 713 -2258 1695 -380 -6740 -1554 -5852 -5191 -539 -9416 -4641 -9198 1265 -6255 401 -4268 -9501 4712 2344 -3904 -7112 -5968 -5705 -2930 -1848 263 -8906 -7146 4690 4699 2675 -5947 3675 -8817 -376 -4162 -879 4556 -2250 -1240 3295
样例输出
-13701