#1230
Unrated
DOMINO
시간 제한
4s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

4 seconds, 512 MB, 160 points Mirko received an N × N table for his birthday, where a non-negative integer is written in each field of the table. Unfortunately, the written numbers are too large for Mirko’s taste, so he will place K dominoes on top of the table that will cover the fields that are too large. More precisely, Mirko places the dominoes according to the following rules:

  • each domino covers two fields of the table that are adjacent in a row or in a column,

  • the dominoes do not overlap (but can touch),

  • the sum of all visible (uncovered) fields needs to be as small as possible.

It is your task to determine the required minimal sum of visible fields. The test data will be such that it will always be possible to place K dominoes without overlapping..

입력

The first line of input contains the integers N (1 ⩽N ⩽2000), the dimensions of the table, and K (1 ⩽K ⩽8), the number of dominoes. Each of the following N lines contains N integers from the interval [0, 1000]. These N × N numbers describe Mirko’s table.

출력

The first and only line of output must contain the minimal sum of visible fields after covering the table with dominoes.

예제 입력 1

3 1
2 7 6
9 5 1
4 3 8

예제 출력 1

31

예제 입력 2

4 2
1 2 4 0
4 0 5 4
0 3 5 1
1 0 4 1

예제 출력 2

17
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.