codeforces 446B(优先队列)
题目链接:http://codeforces.com/problemset/problem/446/B
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+3;
int matrix[N][N];
ll row[N],col[N];
ll dpr[N*N],dpc[N*N];
priority_queue <ll> q;
int main()
{
ll n,m,k,p;
scanf("%I64d%I64d%I64d%I64d",&n,&m,&k,&p);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
scanf("%d",&matrix[i][j]);
row[i]+=matrix[i][j];
col[j]+=matrix[i][j];
}
}
for(int i=1;i<=n;i++)
q.push(row[i]);
for(int i=1;i<=k;i++)
{
ll temp=q.top();
q.pop();
dpr[i]=dpr[i-1]+temp;
temp-=m*p;
q.push(temp);
}
while(!q.empty()) q.pop();
for(int i=1;i<=m;i++)
q.push(col[i]);
for(int i=1;i<=k;i++)
{
ll temp=q.top();
q.pop();
dpc[i]=dpc[i-1]+temp;
temp-=n*p;
q.push(temp);
}
ll ans=dpr[0]+dpc[k];
for(ll i=1;i<=k;i++)
ans=max(ans,dpr[i]+dpc[k-i]-i*(k-i)*p);
printf("%I64d\n",ans);
return 0;
}
codeforces 446B(优先队列)的更多相关文章
- CodeForces 446B DZY Loves Modification
题意: k次操作 每次选择一行或一列 得到所选数字的和 并将所选数字同一时候减去p 问最多得到多少 思路: 重点在消除行列间的相互影响 因为每选一行全部列所相应的和都会-p 那么假设选了i次 ...
- CodeForces 446B
DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 【组队赛三】-D 优先队列 cf446B
DZY Loves Modification Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Sub ...
- 11.1 正睿停课训练 Day14
目录 2018.11.1 正睿停课训练 Day14 A 字符串 B 取数游戏(贪心) C 魔方(模拟) 考试代码 B C 2018.11.1 正睿停课训练 Day14 时间:3.5h 期望得分:100 ...
- codeforces 725D . Contest Balloons(贪心+优先队列)
题目链接:codeforces 725D . Contest Balloons 先按气球数从大到小排序求出初始名次,并把名次排在第一队前面的队放入优先队列,按w-t-1值从小到大优先,然后依次给气球给 ...
- Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列
C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)(A.暴力,B.优先队列,C.dp乱搞)
A. Carrot Cakes time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...
- Educational Codeforces Round 62 (Rated for Div. 2) C 贪心 + 优先队列 + 反向处理
https://codeforces.com/contest/1140/problem/C 题意 每首歌有\(t_i\)和\(b_i\)两个值,最多挑选m首歌,使得sum(\(t_i\))*min(\ ...
- Codeforces 1132D - Stressful Training - [二分+贪心+优先队列]
题目链接:https://codeforces.com/contest/1132/problem/D 题意: 有 $n$ 个学生,他们的电脑有初始电量 $a[1 \sim n]$,他们的电脑每分钟会耗 ...
随机推荐
- css width="100" style ="width:100px" 区别
1. width="100"是正确的,而 width="100px"是错误的, style = "width:100px"是正确的 2. s ...
- Oracle、Microsoft SQL Server、Mysql
数据库对比.----1.Oracle:最贵,功能最多,安装最不方便,Oracle环境里的其他相关组件最多,支持平台数量一般,使用中等方便,开发中等方便,运维中等方便,不开源,速度最慢,最安全.---- ...
- [问题2015S07] 复旦高等代数 II(14级)每周一题(第八教学周)
[问题2015S07] 设 \(A\) 为 \(n\) 阶复方阵, 证明: 存在 \(n\) 阶非异复对称阵 \(S\), 使得 \(A'=S^{-1}AS\), 即 \(A\) 可通过非异复对称阵 ...
- Training
Purley Skylake RAS training: https://cisco.webex.com/ciscosales/lsr.php?RCID=8042a15a27aa46509a91d8f ...
- Linux Shell 批量更换文件名或后缀名
把下列所有.c的文件名修改为.cc rename .c .cc *.c
- ExceptionExtensions
public static class ExceptionExtensions { public static IEnumerable<Exception> GetAllException ...
- FormData、Blob、File、ArrayBuffer数据类型
XMLHttpRequest 1.0 1.0 中xmlhttpRequest有2个重要的返回属性,reposeText,reposeXml.下面的数据类型都是2.0新增的 FormData对象 我们应 ...
- SQL语言增加、修改、删除数据的语法
增加 insert into 表名(字段1,字段2) values ('字段1的值','字段2的值'); 修改 update 表名 set 字段1='赋予字段1的新值',字段2='赋予字段2的新值' ...
- idea首次提交项目
http://www.cnblogs.com/exmyth/p/6133289.html
- android通知栏Notification点击,取消,清除响应事件
主要是检测android通知栏的三种状态的响应事件 这次在实现推送需求的时候,要用到android通知栏Notification点击后进入消息页面,因为要实现一个保存推送用户名字的功能,我在点击后处理 ...