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

.

最新文章

  1. 关于Android中查看app安装时间等信息的问题
  2. 今天第一节PS课
  3. 《第一行代码--Android》阅读笔记之界面设计
  4. h5 web模板
  5. python查询mysql中文乱码问题
  6. iOS 获取导航栏和状态栏的高度
  7. numpy模块中的sum(axis)方法
  8. JAVA线程池原理详解(1)
  9. 使用vue开发项目需要注意的问题和可能踩到的坑
  10. PyQt4转换ui为py文件需添加如下代码才可执行
  11. django中的一对一、一对多、多对多及ForeignKey()
  12. python爬虫,爬取一系列新闻
  13. 通俗理解word2vec
  14. MATLAB:SMPD无法启动
  15. 微信小程序跨页面获取数据示例
  16. File System Object(FSO对象)B
  17. python学习笔记——多进程中共享内存Value &amp; Array
  18. Template7学习记录
  19. Raw-OS源代码分析之idle任务
  20. 《OD面试》Java面试题整理

热门文章

  1. 实现一个带有指纹加密功能的笔记本(Android)第一部分
  2. xss挑战赛小记 0x03(xssgame)
  3. AWS安装CDH5.3-CentOS6.4
  4. 高德API+.NET解决租房问题(可能是最可靠房源:上海互助租房)
  5. Linux 下 PHP 扩展 PDO 编译安装
  6. DDoS 攻击与防御:从原理到实践(下)
  7. 获得通讯录并拨打电话 Android
  8. vue2.0 $emit $on组件通信
  9. 「暑期训练」「基础DP」 Monkey and Banana (HDU-1069)
  10. 序列化反序列化--Xstream的使用