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:

  1. Initially Ivan's score is 0;
  2. 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;
  3. 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.

【翻译】给出01矩阵,要求删除1的点(可以不删),使得得分最大。得分计算方式:得分为每列的得分和,每列的得分计算方式为:从上往下第一个为1的位置向下的k长度区间内1的个数即分数(包括这个位置本身)。输出最高分数以及达成这个分数的最小删除数。

题解:
      ①贪心。

      ②每一列用单调性维护取最值就是了。

#include<stdio.h>
#include<algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
#define ro(i,a,b) for(int i=a;i>=b;i--)
using namespace std;const int N=;
int n,m,k,G[N][N],sum[N],score,ans;
int main()
{
scanf("%d%d%d",&n,&m,&k);
go(i,,n)go(j,,m)scanf("%d",&G[i][j]);
go(j,,m)
{
int p,val=;
ro(t,n,)sum[t]=sum[t+]+G[t][j];
ro(t,n,)if(G[t][j]&&sum[t]-sum[min(t+k,n+)]>=val)
val=sum[t]-sum[min(t+k,n+)],p=t;ans+=sum[]-sum[p];score+=val;
}
printf("%d %d\n",score,ans);return ;
}//Paul_Guderian

.

【CF edu 30 C. Strange Game On Matrix】的更多相关文章

  1. 【CF edu 30 D. Merge Sort】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  2. 【Cf edu 30 B. Balanced Substring】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  3. 【CF edu 30 A. Chores】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  4. 【CF MEMSQL 3.0 D. Third Month Insanity】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  5. 【CF MEMSQL 3.0 B. Lazy Security Guard】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  6. B. Lost Number【CF交互题 暴力】

    B. Lost Number[CF交互题 暴力] This is an interactive problem. Remember to flush your output while communi ...

  7. 【2018.07.30】(广度优先搜索算法/队列)学习BFS算法小记

    一些BFS参考的博客: https://blog.csdn.net/ldx19980108/article/details/78641127 https://blog.csdn.net/u011437 ...

  8. 【Python五篇慢慢弹(5)】类的继承案例解析,python相关知识延伸

    类的继承案例解析,python相关知识延伸 作者:白宁超 2016年10月10日22:36:57 摘要:继<快速上手学python>一文之后,笔者又将python官方文档认真学习下.官方给 ...

  9. 让时间处理简单化 【第三方扩展类库org.apache.commons.lang.time】

    JAVA的时间日期处理一直是一个比较复杂的问题,大多数程序员都不能很轻松的来处理这些问题.首先Java中关于时间的类,从 JDK 1.1 开始,Date的作用很有限,相应的功能已由Calendar与D ...

随机推荐

  1. BigData--hadoop集群搭建之hbase安装

    之前在hadoop-2.7.3 基础上搭建hbase 详情请见:https://www.cnblogs.com/aronyao/p/hadoop.html 基础条件:先配置完成zookeeper 准备 ...

  2. JDK8新垃圾回收机制--G1垃圾回收机制

    G1全称是Garbage First Garbage Collector,使用G1的目的是简化性能优化的复杂性.例如,G1的主要输入参数是初始化和最大Java堆大小.最大GC中断时间. G1 GC由Y ...

  3. 用ssh进行git clone出现 fatal: Could not read from remote repository.

    问题:在通过MobaXterm进行ssh连接的服务器上用ssh进行git clone出现 fatal: Could not read from remote repository. 解决方法:prox ...

  4. go学习笔记-运算符

    运算符 运算符 内置运算符 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 其他运算符 算术运算符 假定 A 值为 10,B 值为 20. 运算符 描述 实例 + 相加 A + B 输出结果 ...

  5. java 堆栈内存分析详解

    计算机术语里面堆和栈代表不同的存储结构:stack-栈:heap-堆 所以java虚拟机(JVM)中堆和栈是两种内存 堆.栈对比 对比点 堆 栈 JVM中的功能 内存数据区 内存指令区 动静态 运行时 ...

  6. VS2010安装MVC3出错

             开始已经在电脑上安装了VS2010以及SP1,还装了MVC4的相关升级包.最后项目中又要用MVC3,然后又去安装MVC3的安装包,但是在安装的过程就出现了问题.一直安装不成功,最后在 ...

  7. android开源项目之OTTO事件总线(一)

    Otto是由Square发布的一个着重于Android支持的基于Guava的强大的事件总线,在对应用程序不同部分进行解耦之后,仍然允许它们进行有效的沟通. 开源项目地址:https://github. ...

  8. 用gradle编译任意结构的Android项目

    ## 需求 * 继续用`Eclipse`项目的结构,但是使用`gradle`编译,或者说任意的项目结构进行编译. ## 解决方案 1. Android studio的项目结构 1. Android S ...

  9. MySQL高可用之PXC安装部署

      Preface       Today,I'm gonna implement a PXC,Let's see the procedure.   Framework   Hostname IP P ...

  10. 使用hibernate连接Oracle时的权限问题

    在使用hibernate对象关系映射连接和创建表的时候,会涉及到很多权限问题,有些数据库管理会将权限设的很细,我们可以根据后台日志错误和异常信息作出判断. 比如下图所示这个错误(这是我在给银行投产系统 ...