codeforces——873C —— Strange Game On Matrix

2873 단어 codeforces
C. Strange Game On Matrix
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score is 0;
In each column, Ivan will find the topmost 1 (that is, if the current column is j, then he will find minimum i such that ai, j = 1). If there are no 1's in the column, this column is skipped;
Ivan will look at the next min(k, n - i + 1) elements in this column (starting from the element he found) and count the number of 1's among these elements. This number will be added to his score.
Of course, Ivan wants to maximize his score in this strange game. Also he doesn't want to change many elements, so he will replace the minimum possible number of ones with zeroes. Help him to determine the maximum possible score he can get and the minimum possible number of replacements required to achieve that score.
Input
The first line contains three integer numbers n, m and k (1 ≤ k ≤ n ≤ 100, 1 ≤ m ≤ 100).
Then n lines follow, i-th of them contains m integer numbers — the elements of i-th row of matrix a. Each number is either 0 or 1.
Output
Print two numbers: the maximum possible score Ivan can get and the minimum number of replacements required to get this score.
Examples
input
4 3 2
0 1 0
1 0 1
0 1 0
1 1 1

output
4 1

input
3 2 1
1 0
0 1
0 0

output
2 0

Note
In the first example Ivan will replace the element a1, 2.
n*m의 행렬이 있는데, 0,1로 구성되어 있다.조작이 있으면 1을 0으로 수정할 수 있습니다
점수 계산 방식은 매 열의 첫 번째 1(첫 번째 1 포함), 길이가 k인 수조를 통계하고 1의 개수를 가진다...각 열의 결과 구화
최소한의 조작 횟수에서 얻을 수 있는 최대 결과를 묻는다..
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
int main() {
    int n,m,len,in[108][108];
    while(~scanf("%d%d%d",&n,&m,&len)) {
        for(int i=0; ilarge) {
                    large=sum;
                    place=i;
                }
            }
            if(large) {
                ans1+=large;
                for(int i=0; i

좋은 웹페이지 즐겨찾기