CodeForces 446B DZY Loves Modification】的更多相关文章

题意: k次操作  每次选择一行或一列  得到所选数字的和  并将所选数字同一时候减去p  问最多得到多少 思路: 重点在消除行列间的相互影响 因为每选一行全部列所相应的和都会-p  那么假设选了i次行  则列会-i*p  同理选列 那么影响就能够这样表示 -p*i*(k-i)  把影响提出来  这样行列就不影响了 对于行或列  单独处理时相当于一维的东西  贪心就可以 代码: #include<cstdio> #include<cstring> #include<algor…
447D - DZY Loves Modification 思路:将行和列分开考虑.用优先队列,计算出行操作i次的幸福值r[i],再计算出列操作i次的幸福值c[i].然后将行取i次操作和列取k-i次操作,那么多加的幸福值就是i*(k-i)*p,因为无论先操作行还是列,每操作一次一个格子只减一次p.这样记录下最大的幸福值. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long ; ; const ll INF=…
B. DZY Loves Modification 题目连接: http://www.codeforces.com/contest/446/problem/B Description As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decided to modify the matrix with exactly k opera…
D. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decid…
D - DZY Loves Modification As we know, DZY loves playing games. One day DZY decided to play with a n × mmatrix. To be more precise, he decided to modify the matrix with exactly koperations. Each modification is one of the following: Pick some row of…
枚举行取了多少次,如行取了i次,列就取了k-i次,假设行列单独贪心考虑然后相加,那么有i*(k-i)个交点是多出来的:dpr[i]+dpc[k-i]-i*(k-i)*p 枚举i取最大值.... B. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As we know, DZY l…
题目大意:Codeforces 444C DZY Loves Colors 题目大意:两种操作,1是改动区间上l到r上面德值为x,2是询问l到r区间总的改动值. 解题思路:线段树模板题. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; const int maxn = 5*1e5; typedef long lo…
D. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decid…
B. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decid…
题目链接:Codeforces 444A DZY Loves Physics 题目大意:给出一张图,图中的每一个节点,每条边都有一个权值.如今有从中挑出一张子图,要求子图联通,而且被选中的随意两点.假设存在边,则一定要被选中.问说点的权值和/边的权值和最大是多少. 解题思路:是图论中的一个结论,最多两个节点.所以枚举两条边就能够了.我简单的推了一下,2个点的情况肯定比3个点的优. 如果有3个点a,b,c,权值分别为A,B.C 现a-b,b-c边的权值分别为u.v 那么对于两点的情况有A+Bu,B…