ACM篇:CF 446B -- DZY Loves Modification
来源:互联网 发布:组织架构优化调整方案 编辑:程序博客网 时间:2024/06/06 14:07
不会。
网上看的题解。
优先队列+枚举
#include <cstdio>#include <iostream>#include <cstring>#include <queue>#define LL long long#define max(A, B) ( ((A)>(B)) ? (A) : (B) )using namespace std;const int MAX = 1000;const int K = 1000005;LL row[MAX+24];LL col[MAX+24]; LL dpr[K];LL dpc[K];int matrix[MAX+2][MAX+2];priority_queue<LL>q;int n;int m;int k;int p;void get_sum(){ 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]; }}void work(LL *arr,LL *sum, int sz, int minus){ while(!q.empty()) q.pop(); for (int i = 1; i <= sz; i++) q.push(sum[i]); for (int i = 1; i <= k; i++) { arr[i] = arr[i-1] + q.top(); q.push(q.top() - minus); q.pop(); }}int main(){ LL ans; ans = -1LL<<60; scanf("%d%d%d%d", &n, &m, &k, &p); get_sum(); work(dpr, row, n, m*p); work(dpc, col, m, n*p); for (int i = 0; i <= k; i++) ans = max(ans, dpr[i] + dpc[k-i] - 1LL*i*(k-i)*p); printf("%lld", ans); return 0;}
0 0
- ACM篇:CF 446B -- DZY Loves Modification
- CF 446B DZY Loves Modification 优先队列
- 【杂题】 codeforces 446B - DZY Loves Modification
- CodeForces 446B DZY Loves Modification
- CodeForces 446-B. DZY Loves Modification
- Codeforces 446B DZY Loves Modification
- codeforces 446B DZY Loves Modification(枚举)
- CF 255 DIV2 D DZY Loves Modification(优先队列)
- D. DZY Loves Modification
- DZY Loves Modification
- DZY Loves Modification CodeForces
- DZY Loves Modification CodeForces
- Codeforces 446B DZY Loves Modification 矩阵行列分开考虑 优先队列+构造
- CodeForces 446B DZY Loves Modification 经典+贪心+更换遍历对象
- Codeforces Round #FF (Div. 1) B. DZY Loves Modification
- CF 447B(DZY Loves Strings-贪心)
- E--DZY Loves Chemistry(CF-445B
- CF 447B DZY Loves Strings(水题)
- [乐意黎原创] 解决被强制篡改主页为流氓360首页的方法
- (int*)0
- 如何配置iptables与tc限制带宽和流量
- 产品从无到有
- u-boot-2016.11移植至S5PV210-单板配置
- ACM篇:CF 446B -- DZY Loves Modification
- MongoDB sharding迁移(一)
- [算法]括号字符串是否合法
- 【Redis笔记】 第5篇: redis监控工具-redis sentinel使用说明及注意事项
- location对象的href和hash属性
- no applicable action for [onMismatch]
- 安装PIL问题
- jsp页面第一行出错
- web基础